2

Is there a practical way (in general) to create a right-to-left Horizontal-ListView in Android?

I already searched about it and find this but its doesn't seem generally practical!

Community
  • 1
  • 1
Jalal Aghazadeh
  • 164
  • 4
  • 18
  • In my case I use HorizontalScrollView with 1 linear layout inside. And then, I populate the linearlayout programatically something like: linearlayout1.addView(listviewitem); //Note listviewitem is any kind of view. – Sheychan Jul 07 '15 at 09:00
  • please check this answer: [link](https://stackoverflow.com/questions/31728837/recyclerview-grow-element-from-right-to-left/46315909#46315909) – Sajad Rahmanipour Oct 11 '17 at 08:15
  • see this post https://stackoverflow.com/a/52905575/4797289 – Rasoul Miri Oct 20 '18 at 12:24

2 Answers2

4

RecyclerView helped me out (instead of horizontal-list-view) {thanX to @user2641570}.

accordding to documentation:

public LinearLayoutManager (Context context, int orientation, boolean reverseLayout)

Parameters context Current context, will be used to access resources.

orientation Layout orientation. Should be HORIZONTAL or VERTICAL.

reverseLayout When set to true, layouts from end to start.

so I just declare LinearLayoutManager as follows:

LinearLayoutManager layoutManager = new LinearLayoutManager(this,LinearLayoutManager.HORIZONTAL, true);

and everything is OK.

Jalal Aghazadeh
  • 164
  • 4
  • 18
1

You should try using RecyclerView.

Here is a post explaining how to use it for an horizontal list view.

Edit:

Here is a sample from the linked post.

LinearLayoutManager layoutManager
    = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);

RecyclerView myList = findViewById(R.id.my_recycler_view);
myList.setLayoutManager(layoutManager);

To use RecyclerView you should import the corresponding support library.

com.android.support:recyclerview-v7:21.0.0
Community
  • 1
  • 1
user2641570
  • 804
  • 8
  • 20
  • as I searched about RecycleView in: http://stackoverflow.com/questions/27727354/linearlayoutmanager-setreverselayout-true-but-items-stack-from-bottom, it is possible to make it Horizontal & RTL, but my minSdk is 11. is RecycleView OK with it? – Jalal Aghazadeh Jul 08 '15 at 05:07
  • I have not tried this but -v7 in the artificat id means that it should be compatible with all android version greater than 7 so it should work. – user2641570 Jul 08 '15 at 08:12