Tôi đã tìm kiếm vài giờ nhưng không tìm thấy bất kỳ điều gì theo yêu cầu của bạn. Nhưng có một số trikes hoặc làm với một số mã hacky chúng tôi có thể nhận được đầu ra theo yêu cầu của bạn.
Đặt RecyclerView như dưới đây trong tệp xml của bạn.
<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"/>
Đặt dữ liệu của bạn trong revers đặt trong List hoặc ArrayList của bạn bởi vì chúng ta cần phải xoay recyclerviews như vậy khi chúng tôi xoay nó sau đó dữ liệu của chúng tôi sẽ được hiển thị như một trật tự 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();
}
Cuối cùng, trong bộ điều hợp của bạn, vui lòng xoay tất cả chế độ xem theo hướng ngược lại như dưới đây.
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);
}
}
Nếu bạn làm mã như trên thì mục của bạn và sản lượng của nó trông như thế này OutPut
Hãy chắc chắn để thực hiện loại mã này vì Android sẽ không chịu trách nhiệm cho các loại mã này, nhưng theo yêu cầu của bạn, bạn có thể làm như thế này.
có giao diện https://imgur.com/a/3WI9v mà thanh cuộn của bạn ở trên cùng. nếu bạn muốn như thế thì hãy ping tôi. – Shailesh