フラグメントで recyclerview を使用しました。アクティビティの configChanges に向きが含まれている場合、電話の向きが横向きから縦向きに変わった後、リサイクラー ビューが画面の中央に表示されます。ただし、常に一番上にある必要があります。configChanges に向きが含まれていない場合、向きの変更時に常に一番上に表示されます。
何が原因か分かりますか?
これはアクティビティのレイアウトです
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.butterfly.LoginActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.AppBarLayout>
<FrameLayout
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:id="@+id/butterflypi_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="top|start" />
</android.support.design.widget.CoordinatorLayout>
これは、上記のフレーム レイアウトを置き換えるフラグメント レイアウトです。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="8dp"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
tools:context="com.butterfly.fragment.ButterflyPIsFragment">
<android.support.v7.widget.RecyclerView
android:id="@+id/my_pi_recycler_view"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
/>
</RelativeLayout>