i have a horizontalscrollview with a LinearLayout inside, i add some views to linear layout , the views are buttons! but the thing is they add to linear layout from left to right , i want them to add from right to left , how can i achieve this?
this is my layout :
<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/filteringSearchBox"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:layoutDirection="rtl" >
<LinearLayout
android:id="@+id/filteringHeaderLL"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp"
android:gravity="end"
android:layoutDirection="rtl"
android:orientation="horizontal" >
</LinearLayout>
</HorizontalScrollView>
i played around with layoutDirection and gravity , none of them works please give me full answer
this is the code :
for (int i = 0; i < mFilteringWB.length; i++) {
Button mButton = new Button(mContext);
mButton.setId(i);
mButton.setTextColor(Color.parseColor("#6D6D6D"));
mButton.setTextSize(13);
mButton.setBackgroundResource(R.drawable.shad_filtering);
mButton.setTypeface(mFace);
mButton.setText(mFilteringWB[i]);
mLayout.addView(mButton);
}
Use addView(View child, int index) instead of void addView(View child)
mylinearLayout.add(myButton, 0); // add new views to index 0 which is left