【发布时间】:2016-01-09 06:53:22
【问题描述】:
我有一个显示动态内容的 RecyclerView。我想在其他视图之间显示这个 RecyclerView。比如RecyclerView上面显示一个View,下面显示一个View:
View
RecyclerView
View
但是,无论我尝试什么似乎都不起作用,并且 RecyclerView 似乎占据了整个空间。我相信问题出在wrap_content issue,虽然我尝试了一些建议的解决方案,例如this custom LinearLayoutManager,但它似乎并没有解决我的问题。
尝试:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!-- AppBar works fine; no issue here -->
<android.support.design.widget.AppBarLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="@+id/app_bar_layout">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_height="?attr/actionBarSize"
android:layout_width="match_parent"
app:layout_collapseMode="pin"/>
</android.support.design.widget.AppBarLayout>
<!-- Not displaying; Tried different views -->
<com.chrynan.taginput.view.TextInputWrapper
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/edit_text_container">
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/edit_text"/>
</com.chrynan.taginput.view.TextInputWrapper>
<!-- Takes up entire screen space -->
<android.support.v4.widget.SwipeRefreshLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/swipe_refresh">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/recycler_view"/>
</android.support.v4.widget.SwipeRefreshLayout>
<!-- Not displaying -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/text_view"/>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
问题:有没有办法在 RecyclerView 上方放置和显示 View 和下方的 View?如果是这样,怎么做?还是使用 ListView 更好?
【问题讨论】:
标签: android android-recyclerview android-design-library