【发布时间】:2013-09-03 19:00:50
【问题描述】:
我制作了使用 Listview 的 App
main_acivity.xml
<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"
android:background="@drawable/common_bg_common"
tools:context=".MainActivity" >
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#000000"
android:dividerHeight="3sp" >
</ListView>
</RelativeLayout>
costomItem 在下面
costomo_cell.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF" >
<LinearLayout
android:id="@+id/linear1"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_alignParentTop="true"
android:background="#cc9933"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical|center_horizontal"
android:text="dummyCanvas"
android:textColor="#000000" />
</LinearLayout>
<LinearLayout
android:id="@+id/linear2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/linear1"
android:background="#cc3333"
android:orientation="vertical" >
<TextView
android:id="@+id/_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000000"/>
</LinearLayout>
</RelativeLayout>
现在,我想按一项填满屏幕。 我想在 custom_cell.xml 中写 match_parent,但不能。
我不想写 xxdp。 Linear1 是屏幕尺寸的 2/3。 其他内容(linear2)是 1/3 大小...
如何配置自定义单元格布局?
--------已编辑--- 我上传截图。 黑线是一项单独的项目。 我想调整屏幕尺寸
【问题讨论】:
-
您是否为 Listview 创建了适配器以将数据与您的自定义布局绑定?
-
你想只用一项来填满整个屏幕吗?
-
@Premsuraj 我试过这个,但没有用。
-
@Grishu 是的,我创建了 CotomAdapter 扩展了 Arrayadapter,并在 getview() 中扩展了 custom_cell.xml
标签: android android-layout android-listview