Ped*_*ira 9 layout android listview textview relativelayout
我正在尝试将TextView放在顶部,另一个放在底部,并使用剩余空间放置一个ListView.但是,我的ListView将所有空间都放在底部,使得最后一个TextView甚至不显示.我能让它显示的唯一方法是给ListView一个固定的高度,比如100dp.
我的布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:id="@+id/id_task_list_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/title_task_list"
style="?android:attr/listSeparatorTextViewStyle" />
<ListView
android:id="@+id/id_task_list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/id_task_list_title" />
<TextView
android:id="@+id/id_task_list_test"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/id_task_list_view"
android:text="OMG Test" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
Amu*_*are 10
使用LinearLayout如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity"
android:orientation="vertical">
<TextView
android:id="@+id/id_task_list_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/title_task_list"
style="?android:attr/listSeparatorTextViewStyle" />
<ListView
android:id="@+id/id_task_list_view"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<TextView
android:id="@+id/id_task_list_test"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="OMG Test" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3960 次 |
| 最近记录: |