如何在ExpandableRelativeLayout中实现listView?

时间:2018-08-04 10:42:11

标签: android listview expandablelistview

我想在listView内实现ExpandableRelativeLayout,但是listview不滚动,并且列表的其余部分无法显示。我希望它像附件的图像一样,在RecyclerView上方的EditText和在ListView下方的EditText,当用户搜索名称时显示。

enter image description here

1 个答案:

答案 0 :(得分:0)

public class MyListView  extends ListView {

    public MyListView  (Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MyListView  (Context context) {
        super(context);
    }

    public MyListView  (Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
                MeasureSpec.AT_MOST);
        super.onMeasure(widthMeasureSpec, expandSpec);
    } }

 <yourPackageName.MyListView
      android:id="@+id/lstsemtrack"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:divider="#f2e4e4"
      android:dividerHeight="1dip">
 </yourPackageName.ListView>

请按照customListView进行操作,该操作将根据内容确定高度。