开发者

RelativeLayout, Include and layout_alignParentBottom doesn't work

How do I let my include exactly at the end of the screen? At the time he gets to the end of the content.

<!-- language: lang-xml -->
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent">
    <ScrollView android:layout_width="fill_parent"
        android:layout_height="fill_parent" android:background="#f6ba79"
        android:orientation="vertical" android:id="@+id/layout">
        <LinearLayout android:id="@+id/linearLayout2"
            android:orientation="vertical" android:layout_width="fill_parent"
            android:layout_height="fill_parent" android:background="@drawable/preferences_background">
            <include android:id="@+id/include1" android:layout_width="fill_parent"
                layout="@layout/top" android:layout_height="wrap_content"></include>
            <LinearLayout android:layout_width="fill_parent"
                android:gravity="center" android:id="@+id/linearLayout1"
                android:layout_height="wrap_content">
                <LinearLayout android:orientation="vertical"
                    android:layout_width="270dp" android:id="@+id/body"
                    android:layout_height="wrap_content" android:focusableInTouchMode="true">
                    <ImageView android:src="@drawable/preferences"
                        style="@style/Theme.Connector.ImageElement" android:layout_width="wrap_content"
                        android:id="@+id/title" android:layout_height="wrap_content"></ImageView>
                    <Spinner android:layout_width="fill_parent"
                        style="@style/Theme.Connector.WelcomeSpinner"
                        android:layout_weight="1" android:id="@+id/spinner_isp"
                        android:layout_height="wrap_content" />
                    <EditText android:singleLine="true" android:hint="@string/txt_user"
                        android:layout_height="wrap_content" android:layout_width="fill_parent"
                        android:id="@+id/edit_user" style="@style/Theme.Connector.PreferencesInput" />
                    <EditText android:singleLine="true" android:hint="@string/txt_password"
                        android:layout_height="wrap_content" android:layout_width="fill_parent"
                        android:id="@+id/edit_password" android:password="true"
                        style="@style/Theme.Connector.PreferencesInput" />
                    <LinearLayout android:orientation="vertical"
                        android:layout_width="fill_parent" android:id="@+id/frm_action"
                        android:layout_height="fill_parent" android:baselineAligned="false">
                        <Button android:text="@string/btn_save"
                            android:layout_weight="0" android:layout_width="130dp"
                            android:layout_height="wrap_content" style="@style/Theme.Connector.Button"
                            android:layout_gravity="center" android:id="@+id/btn_save"></Button>
                    </LinearLayout>
                </LinearLayout>
            </LinearLayout>
        </LinearLayout>
    </ScrollView>
        <include android:id="@+id/include1" android:layout_width="fill_parent"
            layout="@layout/menu" android:layout_height="wrap_content" android:layout_alignParentBottom="true"></include&开发者_运维问答gt;
</RelativeLayout>

RelativeLayout, Include and layout_alignParentBottom doesn't work


The problem is that your ScrollerView has a layout_height="fill_parent". RelativeLayout will make that view fill the entire space.

A LinearLayout will work better in your case:

<?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:orientation="vertical">
    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:background="#f6ba79"
        android:orientation="vertical"
        android:id="@+id/layout">

        ...

    </ScrollView>
    <include
        android:id="@+id/include1"
        android:layout_width="fill_parent"
        layout="@layout/menu"
        android:layout_height="wrap_content" />
</LinearLayout>

The key here is to have the height of the ScrollerView set to 0dp and the weight set to 1 (or any number really). LinearLayout will then stretch the ScrollerView to fill the view and still make room for the @layout/menu at the bottom.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜