我正在测试应用程序。我需要显示问题和选项。针对每个问题的选项数量在手之前是未知的。即为每个问题有不同数量的选项,因此我动态显示选项。如何在android中正确修复布局?
我的代码:
list.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:id="@+id/linearlayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com.splash.Header
android:id="@+id/layoutheader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
<ListView
android:layout_height="wrap_content"
android:id="@+id/listview"
android:layout_width="fill_parent">
</ListView>
</LinearLayout>
header.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<ImageView
android:id="@+id/topbar"
android:layout_width="330dip"
android:layout_height="wrap_content"
android:background="@drawable/topplain"
>
</ImageView>
<ImageView
android:id="@+id/home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/homebtn"
android:layout_marginTop="4dp"
android:layout_alignParentLeft="true"
>
</ImageView>
<ImageView
android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/backbtn"
android:layout_marginTop="4dip"
android:layout_marginLeft="255dip"
android:layout_alignParentRight="true"
android:onClick="back"
>
</ImageView>
</RelativeLayout>
listitem.xml
<?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"
android:background="#FFFFFF"
android:id="@+id/lnrlayout">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tv_question"
android:text=""
android:textColor="#000000"
android:layout_below="@+id/casedescription"
android:layout_marginTop="10dp"
></TextView>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:id="@+id/rlt_main"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:id="@+id/chkboxes"
android:layout_below="@+id/tv_question"
android:layout_alignParentLeft="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
这里我的问题是根据问题的大小布局正在扩大否则布局只显示如图所示的半屏。如何解决这个问题。我尝试了很多来调整布局,但仍面临同样的问题。请帮助我解决这个问题。在此先感谢..
你更好的使用,而不是线性 – Akram 2012-02-13 06:22:11
喜相对布局哪一个,我应该使用相对layout..is对于列表视图? – RaagaSudha 2012-02-13 06:23:27
第一个。 – Akram 2012-02-13 06:24:57