I used recyclerview in fragment. If configChanges activity includes orientation, viewing the recycler appears in the middle of the screen after changing the orientation of the phone from landscape to portrait. However, it should always be on top. If configChanges does not include orientation, it is always displayed at the top when orientation changes.
Do you have any idea what is the reason?
This is an action layout.
<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>
This fragment layout replaces the frame above.
<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>
android android-recyclerview
faraway
source share