我的應用程序圍繞一個HomeActivity進行,它包含底部的4個選項卡。這些標籤中的每一個都是一個片段,所有這些標籤都從一開始就被添加(不會被替換),並且在點擊適當的標籤時隱藏/顯示它們。保存NestedScrollView的滾動狀態
我的問題是,只要我改變標籤,我的滾動狀態就會丟失。顯示該問題的每個片段使用android.support.v4.widget.NestedScrollView
(參見下面的示例)。
注意:由於某些原因,使用RecyclerView或ListView的片段保持其滾動狀態。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/include_appbar_title" />
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Content -->
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
我閱讀了有關節能實例狀態(this one,that one例如)幾個職位,以及他們的解決方案要麼不中我的情況下工作,或者是不實際的工具給我有4-12不同片段我需要修改才能使其工作。
有一個嵌套滾動視圖保持滾動位置的片段變化的最佳方式是什麼?
你我晚上保存:) – ievgen