Я пытаюсь использовать ExpandableListView
с пользовательским адаптером в моем проекте.Как автоматически установить различную высоту элемента в ExpandableListView?
Существует мнение, результат моей деятельности с ExpandableListView
:
Как вы можете видеть, некоторые строки не имеют правильную высоту и некоторые строки обрезаются.
Что я делаю неправильно?
Есть мои файлы разметки
активность раскладка:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ExpandableListView
android:layout_width="matc_parent"
android:layout_height="match_parent"
android:id="@+id/noticeList"/>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/empty"
android:text="@string/empty"/>
</LinearLayout>
и макет для предмета ExpandableListView:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:id="@+id/noticeImage"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="20dp"
android:id="@+id/noticeDate"/>
<TextView
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/noticeTitle"/>
</LinearLayout>
</LinearLayout>
в первом TextView higth составляет 20 дп сделать его wrap_content – Moinkhan
набор 'андроид: строки = 2' для' noticeTitle' TextView – Robust
** 1 ** - Вы можете использовать один RelativeLayout вместо 2 LinearLayouts (более плоский дизайн = лучшие показатели). ** 2 ** - 'fill_parent' устарел. –