Jay*_*ren 6 layout android listview
我有一个列表视图,并希望将它们放在上面(在y轴上)和下面(y轴),包括图像,文本视图和一行按钮.以下是我正在创建的简化版本.不幸的是,列表覆盖了(即在z轴上方)标题,因此标题文本不可见而不是在下面(在y轴上)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:id="@+id/footer"
android:text="footer"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_alignParentBottom="true"
/>
<ListView android:id="@+id/list_view"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_above="@id/footer"
android:background="#ff9999ff"/>
<TextView android:id="@+id/header"
android:text="header"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_alignParentTop="true"
android:layout_above="@id/list_view"
android:baselineAlignBottom="false"
/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
这是相应的Activity类:
public class SampleListActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.list_activity);
}
}
Run Code Online (Sandbox Code Playgroud)
Jay*_*ren 10
我无法让相对布局在Android 1.5中运行,但我确实让Linear Layout工作.以下是我的解决方案:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView android:id="@+id/header"
android:text="header"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="0"
/>
<ListView android:id="@+id/list_view"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:background="#ff9999ff"
android:layout_weight="1"/>
<TextView android:id="@+id/footer"
android:text="footer"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="0"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这应该使用RelativeLayout:
<?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">
<TextView android:id="@+id/header"
android:text="header"
android:layout_height="wrap_content"
android:layout_width="fill_parent" />
<TextView android:id="@+id/footer"
android:text="footer"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_alignParentBottom="true"/>
<ListView android:id="@id/android:list"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_below="@id/header"
android:background="#ff9999ff"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
编辑:删除安卓:方向建议
| 归档时间: |
|
| 查看次数: |
9567 次 |
| 最近记录: |