我已经搜索了几个小时,但没有找到符合您要求的任何内容。但是有一些三轮车或一些hacky代码,我们可以根据您的要求获得输出。
在您的 xml 文件中如下设置您的 RecyclerView。
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbarAlwaysDrawHorizontalTrack="true"
android:scrollbarSize="10dp"
android:scrollbarStyle="outsideInset"
android:scrollbarThumbVertical="@color/black"
android:scrollbars="horizontal"
android:verticalScrollbarPosition="right"/>
将您的数据在您的List 或ArrayList 中以相反的顺序排列,因为我们需要轮换recyclerviews,所以当我们轮换它时,我们的数据将显示为ASEC 订单。
//call this method for set recyclerview
private void setRecyclerView()
{
//Please make sure with your item that it will be inserted in revers order then an then it will be working
ArrayList<String> itemList = new ArrayList<>();
for (int i = 50; i > 0; i--){
itemList.add("item " + i);
}
ContainerAdapter adapterMessage = new ContainerAdapter(MainActivity.this, itemList);
if (adapterMessage != null)
{
rvItemList.setHasFixedSize(true);
rvItemList.setLayoutManager(new LinearLayoutManager(MainActivity.this,
LinearLayoutManager.HORIZONTAL, false);
rvItemList.setItemAnimator(new DefaultItemAnimator());
rvItemList.setAdapter(adapterMessage);
//here is the main line for your requirement
rvItemList.setRotation(180);
adapterMessage.notifyDataSetChanged();
}
最后,在你的适配器中,请像下面这样反向旋转你的所有视图。
public class ViewHolder extends RecyclerView.ViewHolder
{
TextView txt_name;
public ViewHolder(View itemView) {
super(itemView);
txt_name = (TextView) itemView.findViewById(R.id.txt_name);
// here you need to revers rotate your view because your recyclerview is already rotate it so your view is also rotated and you need to revers rotate that view
txt_name.setRotation(-180);
}
}
如果您按照上面的方式编写代码,那么您的项目及其输出将如下所示OutPut
请确保做这种代码,因为android不会对这种代码负责,但根据您的要求,您可以这样做。