-1

私はLinearLayoutにTextViewとListViewを持っていますが、残念ながら小さな画面ではListViewに十分なスペースがありません(約0.5行を表示することを意味します)。まとめて上にスクロールすることはできますか?SDKには、私が使用できるListViewの代替手段はありますか? それとも、ユーザーフレンドリーにする方法が他にあるのでしょうか。

レイアウト.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="5dp"
    android:layout_marginRight="5dp" >

    <TextView
        android:id="@+id/textView5"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="@string/studio"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/textView6"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</LinearLayout>

<ListView
    android:id="@+id/list_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="2" >
</ListView>
</LinearLayout>
4

4 に答える 4

0
There is a better solution for this instead of adding title to the main layout you can add that title to another layout and inflate that layout as header to the listview.

Like this -:

LayoutInflater inflater = getLayoutInflater();
ViewGroup header = (ViewGroup)inflater.inflate(R.layout.title, myListView, false);
myListView.addHeaderView(header, null, false);

レイアウト.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<ListView
    android:id="@+id/list_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
</ListView>

</LinearLayout>


title.xml
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="5dp"
    android:layout_marginRight="5dp" >

    <TextView
        android:id="@+id/textView5"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="@string/studio"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/textView6"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

</LinearLayout>
于 2013-08-13T09:46:18.503 に答える
0

addHeaderViewを使用するためのヘッダー ビューとしてLinearLayout2 s を配置します。TextViewListView

于 2013-08-13T09:26:21.287 に答える