How to make HorizontalScrollView RIGHT on LEFT Scroll android

By default, HorizontalScrollView scrolls from left to right, but I want to scroll from right to left.

How to do it? Any help would be appreciated.

+8
java android android-layout android-activity
source share
2 answers

You can scroll it to the right edge of your scroll in your code something like this:

 postDelayed(new Runnable() { public void run() { scrollView.fullScroll(HorizontalScrollView.FOCUS_RIGHT); } }, 100L); 

Related Q and A fooobar.com/questions/123640 / ...

+9
source share

add layout_gravity ALREADY, this is useful when objects do not cover the hole with

  <HorizontalScrollView android:id="@+id/scrollPartition" android:layout_width="match_parent" android:layout_height="wrap_content" android:scrollbars="none"> <LinearLayout android:id="@+id/lytPartition" android:layout_gravity="right" android:layout_width="wrap_content" android:layout_height="48dp" android:gravity="center_vertical" android:orientation="horizontal" android:paddingLeft="4dp" android:paddingRight="4dp" android:scrollbars="none"> </LinearLayout> </HorizontalScrollView> 

and in the code you need to scroll to the end of the list

  findViewById(R.id.scrollPartition).post(new Runnable() { @Override public void run() { ((HorizontalScrollView) findViewById(R.id.scrollPartition)).fullScroll(View.FOCUS_RIGHT); } }); 

to set layout_gravity programmatically use this:

  HorizontalScrollView scrollView = new HorizontalScrollView(context); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParams.gravity = Gravity.RIGHT; scrollView.setLayoutParams(layoutParams); 
0
source share

All Articles