Центрировать элементы HorizontalScrollView, когда их недостаточно для прокрутки

У меня есть макет с HorizontalScrollView, содержащий LinearLayoutдля меню, в котором содержимое увеличивается с содержимым ДБ. Это прекрасно работает, однако, когда элементов недостаточно для прокрутки HSV, это не заполняет ширину экрана, который в идеале должен быть центрирован. т.е. В настоящее время:

| Element 1 Element 2                         | <- edge of screen

Вместо:

|        Element 1            Element 2       | <- edge of screen

, но все еще в состоянии:

| Element 1 Element 2 Element 3 Element 4 Elem| <- edge of screen now scrolling

XML-код макета:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mainLinearLayout"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <TextView 
         android:id="@+id/header"
         android:layout_width="fill_parent"
         android:layout_height="25dp" >
    </TextView>

    <ScrollView
         android:id="@+id/scroll1"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent"
         android:layout_weight="1" >

        <LinearLayout
             android:id="@+id/contentLayout"
             android:layout_width="fill_parent"
             android:layout_height="wrap_content"
             android:orientation="vertical" >

        </LinearLayout>
    </ScrollView>

    <HorizontalScrollView
        android:id="@+id/horizontalScrollView1"
        android:layout_width="fill_parent"
        android:layout_height="30dp">

        <LinearLayout
            android:id="@+id/footerLayout"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="horizontal" >

        </LinearLayout>
   </HorizontalScrollView>
</LinearLayout>

Со следующим XML-кодом внутри нижнего колонтитула:

<?xml version="1.0" encoding="utf-8"?>

        <TextView
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/footer_content"
            android:textSize="18sp"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:paddingLeft="5dp"
            android:paddingRight="5dp"
            android:text="FOOTER"
            android:singleLine="true" />
14
задан Cœur 27 June 2019 в 14:12
поделиться