代码设置Adapter的Item的高度:
方案一:
- 在xml里面多嵌套一次布局
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="80dp">
<TextView
android:id="@+id/tv_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="item" />
</RelativeLayout>
</android.support.constraint.ConstraintLayout>
方案二:
convertView = mInflater.inflate(R.layout.item_disease, null);
AbsListView.LayoutParams param = new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 70);
convertView.setLayoutParams(param);