HorizontalScrollView with centered elements HorizontalScrollView with centered elements android android

HorizontalScrollView with centered elements


use the gravity attribute :

android:layout_gravity="center_horizontal" EDIT : 03.30 :

I found it ! only had to set the gravity to the upper LinearLayout : all you need to do is add a little padding/margins to make the textviews more comfortable to read !

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:gravity="center_horizontal"    android:orientation="vertical" >    <HorizontalScrollView        android:id="@+id/horizontalScrollView1"        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_gravity="center_horizontal" >        <LinearLayout            android:id="@+id/linearLayout1"            android:layout_width="fill_parent"            android:layout_height="fill_parent"            android:orientation="horizontal" >            <TextView                android:id="@+id/TextView04"                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:text="MenuB" >            </TextView>            <TextView                android:id="@+id/TextView03"                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:text="MenuB" >            </TextView>            <TextView                android:id="@+id/TextView02"                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:text="MenuB" >            </TextView>            <TextView                android:id="@+id/TextView01"                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:text="MenuB" >            </TextView>            <TextView                android:id="@+id/textView1"                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:text="MenuA" >            </TextView>            <TextView                android:id="@+id/textView2"                android:layout_width="wrap_content"                android:layout_height="wrap_content"                android:text="MenuB" >            </TextView>        </LinearLayout>    </HorizontalScrollView></LinearLayout>

keep me posted !