0

私は、ListViewすべてのアイテムにテキスト フィールドのみが含まれ、他には何も含まれていない単純なものを使用しています。リスト項目の xml コードは次のとおりです。

    <?xml version="1.0" encoding="utf-8"?>
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="?android:attr/listPreferredItemHeight">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent" 
            android:layout_marginLeft="6dp"
            android:layout_marginRight="6dp"
            android:layout_marginTop="4dp"
            android:layout_marginBottom="4dp"
            android:background="@drawable/bg_card">


        <TextView
            android:id="@+id/txt"
            android:layout_width="fill_parent"
            android:layout_height="50dp"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:gravity="center_vertical"
            android:textSize="15sp"
            android:paddingLeft="6dip"
            android:textColor="#878787"
            android:textIsSelectable="true"/>

        </LinearLayout>

    </FrameLayout>

リストビューを使用したフラグメントのレイアウトは次のとおりです。

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#e5e5e5">

    <ListView
        android:id="@+id/listView1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="16dp"
        android:dividerHeight="0dp"
        android:divider="@null"/>

    </RelativeLayout>

さて、このように私のフラグメントにアダプターのオブジェクトを作成しながら

Level weather_data[] = new Level[] {
    new Level(R.drawable.s1, 
              "Some text which will be present in the list item",      
              R.drawable.play_button)
        };

2 番目のパラメーター、つまりテキストに非常に長い文がある場合、その一部が表示されず、リスト項目に文が不完全に表示されます。

リスト項目の高さを変更しようとしandroid:minHeightましたが、うまくいきませんでした。これに対する解決策は何ですか?ありがとう

4

2 に答える 2

0

wrap_contentの代わりに設定してみて"?android:attr/listPreferredItemHeight"くださいandroid:layout_height

このようなもの:

 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
于 2013-07-22T14:05:25.543 に答える
0

コンテナを設定するだけで十分でwrap_content、必要に応じてサイズが変更されます。表示されているレイアウトは完全ではなく、ここで何かハードフィックスされている可能性があると思われます:

android:layout_height="?android:attr/listPreferredItemHeight

また、あなたのレイアウトには、ラップTextViewLinearLayoutてからオールインする本当の意味はありませんFrameLayout。パディングとbgを移動しても同じ効果が得られますFrameLayout

于 2013-07-22T13:13:57.500 に答える