【发布时间】:2014-08-17 00:42:39
【问题描述】:
我试图将我的线性布局对齐到整个布局的底部,这是相对的,并在这里找到了解决方案:How to align views at the bottom of the screen?
但是为什么这也行不通呢?
<RelativeLayout 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"
tools:context="com.sandbox.activities.ListActivity">
<ListView
android:id="@+id/my_listview"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:id="@+id/search_footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/my_listview"
android:orientation="horizontal"
android:layout_alignParentBottom="true">
<EditText
android:id="@+id/my_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Enter Search Term" />
<Button
android:id="@+id/find_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Find"
android:onClick="findThings"/>
</LinearLayout>
如果列表视图很短,比如 1 行,“search_footer”就在它的下方,并且它下方有一个巨大的间隙。
1) "search_footer" 被告知在父级的底部对齐,这是相对布局。既然relativelayout的高度是match_parent,而且是根布局,就是屏幕的整个高度,那为什么不管listview大小,“search_footer”都不在屏幕底部呢?
2) 另外,如果我将 search_footer 的高度更改为 match_parent,我希望按钮非常高,但它保持不变——为什么?
【问题讨论】:
标签: android android-layout android-relativelayout