rga*_*ber 12 android android-layout android-linearlayout android-scrollview android-relativelayout
我有一个简单的布局,顶部有一个名字,还有一个我希望位于屏幕底部的按钮,或者我想要添加更多项目的按钮.
所以我使用带有LinearLayout的ScrollView,如下所示:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:fillViewport="true"
android:focusableInTouchMode="true"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
tools:context=".ItemDetailActivity" >
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >
    <!-- Name -->
    <RelativeLayout
        android:id="@+id/top_content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="top" >
        <TextView
            android:id="@+id/name_label"
            style="@style/Header_Label_TextView"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/name" />
        <TextView
            android:id="@+id/name_value"
            style="@style/Value_Label_TextView"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/name_label" />
    </RelativeLayout>
    <!-- button -->
    <RelativeLayout
        android:id="@+id/ButtonLayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom" >
        <Button
            android:id="@+id/add_button"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10sp"
            android:onClick="editItem"
            android:text="@string/button_edit" />
    </RelativeLayout>
    <requestFocus />
</LinearLayout>
这就是我得到的:

如何使按钮出现在屏幕底部或更远处.在线搜索,大多数答案是设置`android:fillViewport ="true",但这没有帮助.我究竟做错了什么?
像这样更改Button布局:
 <RelativeLayout
    android:id="@+id/ButtonLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="bottom" >
    <Button
        android:id="@+id/add_button"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10sp"
        android:onClick="editItem"
        android:layout_alignParentBottom="true"
        android:text="@string/button_edit" />
</RelativeLayout>
| 归档时间: | 
 | 
| 查看次数: | 34422 次 | 
| 最近记录: |