1

I'm using a right-to-left language in my ListView and because it's TextView may need more space, I used HorizontalScrollView. The text should be right align and when the user scrolls down, HorizontalScrollView should scroll to the rightest position (and as you know HorizontalScrollView is stuck in the leftest position at default). this is my ListView row code:

<HorizontalScrollView
            android:id="@+id/hs1"
            android:layout_width="0dp"
            android:paddingRight="5dp"
            android:layout_height="wrap_content"
            android:layout_weight="50" >

            <TextView
                android:id="@+id/txtProductName"
                style="@style/text_black"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="right|center_vertical"
                android:layout_gravity="right|center_vertical"
                android:textSize="@dimen/textsize" />
        </HorizontalScrollView>

and I use the code below in getView of my ListView Adapter for scrolling to right but it doesn't work:

new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    viewHolder.hs1.fullScroll(HorizontalScrollView.FOCUS_RIGHT);
                    viewHolder.hs2.fullScroll(HorizontalScrollView.FOCUS_RIGHT);
                }
            },500);

and at last, I used new Handler().post() too and not working.

Ali Aqa
  • 31
  • 1
  • 7

2 Answers2

2

You will have to use "pagescoll" to goto the next focusable (see the documentation). Hope it helps.....

Replace:

viewHolder.hs1.fullScroll(HorizontalScrollView.FOCUS_RIGHT);
viewHolder.hs2.fullScroll(HorizontalScrollView.FOCUS_RIGHT);

With:

viewHolder.hs1.pageScroll(HorizontalScrollView.FOCUS_RIGHT);
viewHolder.hs2.pageScroll(HorizontalScrollView.FOCUS_RIGHT);
Ashiq
  • 430
  • 1
  • 9
  • 24
1

Finally I found the solution, absolutely at my view when I wanted my HorizontalScrollView to show rtl (right-to-left) textView, The soluion is using RelativeLayout as parent .

Ali Aqa
  • 31
  • 1
  • 7
  • What's the solution @Ali Aqa I'm facing the same issue with Horizontal Scroll View inside a ListView. It automatically goes to the left when I scroll the list. Can you post some code? In my layout, RelativeLayout is the parent too. Thanks. – Rahul Sainani Oct 13 '14 at 12:05