Как я могу расположить дополнительный фиксированный нижний колонтитул под ScrollView? - PullRequest
1 голос
/ 20 июля 2011

Я пытаюсь создать макет Android с фиксированным нижним колонтитулом, а оставшаяся область будет занята ScollView. Сложность заключается в том, что в нижней части ScrollView мне нужен второй «нижний колонтитул», где есть другое изображение, но прикрепленное к нижней части ScrollView, и которое находится за ScrollView (и содержимое прокручивается поверх него. ) Вот визуальный пример .

Когда я использую метод RelativeLayout для создания фиксированного нижнего колонтитула, это работает, но кажется, что занимаемое им пространство не удаляется из общего размера экрана. Я попробовал то, что кажется бесконечной комбинацией методов, и я не могу найти тот, который работает.

Вот то, с чем я работал.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:gravity="top" android:layout_height="fill_parent" android:layout_width="fill_parent" android:background="@drawable/background_image" android:orientation="vertical">
<ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="fill" android:layout_weight="1">
    <FrameLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1">
        <ImageView android:layout_centerHorizontal="true" android:layout_width="fill_parent" android:layout_height="wrap_content" android:src="@drawable/scroll_footer_image" android:layout_gravity="bottom" android:layout_weight="1"></ImageView>
        <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_weight="1">
            <!-- content for the scrollview goes here. -->
        </LinearLayout>
    </FrameLayout>
</ScrollView>
<RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/footer_background_image" android:layout_alignParentBottom="true">
    <ImageView android:scaleType="centerInside" android:layout_gravity="center"  android:clickable="false" android:src="@drawable/footer_contents" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerInParent="true" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:layout_weight="0"></ImageView>
</RelativeLayout>
</LinearLayout> 

1 Ответ

1 голос
/ 20 июля 2011

Хорошо, наконец, похоже, что ответом будет использование android: layout_gravity и android: layout_weight.Это, кажется, делает трюк для меня, без отступов на изображениях.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="fill_parent" android:layout_width="fill_parent" android:background="@drawable/background_image" android:orientation="vertical">
<FrameLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:layout_gravity="fill">
    <ImageView android:src="@drawable/scroll_footer_image" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="bottom" android:layout_gravity="bottom"/>
    <ScrollView android:fillViewport="true" android:layout_width="fill_parent" android:layout_height="fill_parent">
        <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical">
            <!-- additional content goes here -->
        </LinearLayout>
    </ScrollView>
</FrameLayout>

<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_weight="0" android:gravity="bottom">
    <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/footer_topper_image" android:orientation="vertical"/>
    <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/footer_background_image" android:orientation="vertical" android:gravity="center">
        <ImageView android:src="@drawable/footer_contents" android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageView>
    </LinearLayout>
</LinearLayout>

...