I have a RelativeLayout
styled as a ButtonBar
and contained in a HorizontalScrollView
, this layout is a ssigned to a fixed height in order to be controlled but that make it looks giant in small screen devices,
for ex, in a 10' device:
And in a 3.7' device:
And here's my XML code:
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tool"
android:id="@+id/horizontalScrollView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true" >
<RelativeLayout
android:id= "@+id/buttobbar"
android:layout_width="match_parent"
android:layout_height="60dp"
android:gravity="top"
style="@android:style/ButtonBar"
android:background="@drawable/released" >
<Button
android:id="@+id/Main"
android:layout_width="120dp"
android:layout_height="60dp"
android:background="@android:color/transparent"
android:textColor="@android:color/white"
android:textStyle="bold"
android:text="@string/main"/>
<View
android:id="@+id/separator"
android:layout_height="fill_parent"
android:layout_toRightOf="@+id/Main"
android:layout_width="1px"
android:background="@drawable/separators"/>
<Button
android:id="@+id/HomeView"
android:layout_width="120dp"
android:layout_height="60dp"
android:background="@android:color/transparent"
android:textColor="@android:color/white"
android:textStyle="bold"
android:layout_toRightOf="@+id/Main"
android:text="@string/homeview" />
<View
android:id="@+id/separator"
android:layout_height="fill_parent"
android:layout_toRightOf="@+id/HomeView"
android:layout_width="1px"
android:background="@drawable/separators"/>
.
.
. <!-- after 7 other buttons separated with views --!>
</RelativeLayout>
</HorizontalScrollView>
Adding weight would be a best option: Try this:
android:weightSum="1"
and divide this weight sum to the butons as follows:
android:layout_weight=0.5