Android HorizontalScrollView layout components layout

I have a HorizontalScrollView containing a horizontal linear layout when I add a new button to the horizontal linear layout of buttons added next to each other from left to right and when the screen width is exceeded, the new added buttons will not be visible on the screen but horizontal scrolling will appear to scroll to the right
enter image description here
I want the direction of adding a new button to the horizontal linear layout from right to left not left to right.
enter image description here

+4
source share
3 answers

Using:

myLinearLayout.addView(myButton); 

he adds them one by one. But if you use

 myLinearLayout.addView(myButton, 0); 

it adds myButton before the first element in LinearLayout.

In addition to the above code, if you want the HorizontalScrollView to start on the right side, you can use the following code:

 new Handler().postDelayed(new Runnable() { @Override public void run() { hScrollView.fullScroll(HorizontalScrollView.FOCUS_RIGHT); } }, 100L); 
+2
source

I'm doing it. Its API works above 8:

  <HorizontalScrollView android:id="@+id/scrool" android:layout_width="match_parent" android:layout_height="wrap_content" android:rotation="180" android:fillViewport="true"> <LinearLayout android:id="@+id/lytAll" android:layout_width="match_parent" android:rotation="180" android:layout_height="match_parent" android:gravity="right" android:orientation="horizontal"/> </HorizontalScrollView> 
+1
source

you can achieve this simply by using the relative layout and adding a new button with the property

android:layout_toLeftOf=""

0
source

Source: https://habr.com/ru/post/1380701/


All Articles