我试图在我的项目中使用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>
答案 0 :(得分:2)
谢谢大家的回答。
解决方案是使用RelativeLayout
代替LinearLayout
:
<RelativeLayout 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"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/noticeImage"
android:id="@+id/noticeDate"
/>
<TextView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="@+id/noticeTitle"
android:layout_toRightOf="@+id/noticeImage"
android:layout_below="@+id/noticeDate"
/>
</RelativeLayout>
答案 1 :(得分:0)
尝试将layout_height
的{{1}}设置为TextView noticeDate
wrap_content