我在android上執行此應用程序,並注意到當我在頂部向recyclerview添加新項目時,該項目將被appbarlayout阻止。 app screenshot hereAndroid recyclerview新增項目被appbarlayout阻止
例如,如果我添加一個新項目,它將顯示爲「444」之上的第一個項目,但添加後我必須向下滾動才能看到它,否則它會被appbarlayout阻止。
有沒有解決方案?謝謝。
佈局文件:
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="scroll|enterAlways" />
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/crime_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.largerexer.aaronc.criminalintent.CrimeListActivity"
tools:showIn="@layout/activity_fragment"/>
良好的解決方法! –
這不完全是一個工作。數據更改後,Recycler視圖不會自動滾動。 –
謝謝!所以每次改變時,我都必須手動滾動? –