我想在列表视图上方创建文本视图,如下所示:
这是我的XML脚本:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#FFFFFF"
>
<ListView
android:id="@+id/lvVouchers"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
我很困惑在列表视图上方制作textview ...
答案 0 :(得分:1)
试试这个,
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<ListView
android:id="@+id/listView1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.8" >
</ListView>
<TextView
android:id="@+id/text1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2">
</TextView>
但你必须在每个字符之后用\ n设置文本,如下所示,
textView.setText("a" + "\n" + "b" + "\n" +"c" + "\n" +"d" + "\n" );
答案 1 :(得分:0)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#FFFFFF"
>
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TextView>
<ListView
android:id="@+id/lvVouchers"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>