【发布时间】:2018-09-01 18:11:30
【问题描述】:
我有一个 recyclerview 填充了来自 API 的列表。我正在使用 RxBinding 来搜索和过滤列表。当前的问题在于我的布局。我希望我的搜索栏字段位于顶部,列表位于其下方。下面是我的列表被过滤的示例,但您可以看到搜索栏文本和列表项重叠
下面是布局文件。
<?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="match_parent"
android:animateLayoutChanges="true">
<android.support.v7.widget.RecyclerView
android:id="@+id/listRecycler"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatEditText
android:id="@+id/searchView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical"
android:layout_weight="1"
android:background="@android:color/transparent"
android:inputType="text" />
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="end|center_vertical"
android:src="@android:drawable/ic_menu_search" />
</FrameLayout>
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
</FrameLayout>
</FrameLayout>
最终我希望搜索栏也可以滚动,这样当用户向下滚动列表时,搜索栏就会被旋转出来。但是,我认为这将涉及我创建了一些 CommonInterface 的列表,我的 SearchBar 和 ListItems 都必须实现。
【问题讨论】:
标签: android android-layout android-recyclerview android-linearlayout recyclerview-layout