Фрагмент, не использующий макет ландшафта при изменении ориентации - PullRequest
0 голосов
/ 03 июня 2018

Я создал альбомную версию фрагмента, нажав кнопку «Создать альбомную версию» над окном предварительного просмотра.Затем я внес некоторые изменения в файл макета ландшафта.Но когда ориентация изменена, фрагмент не использует альбомную версию этого фрагмента.

В манифесте я добавил android:configChanges="orientation|keyboardHidden|screenSize" к действию, содержащему этот фрагмент.

Но это не сработало.

Портретная версия

frag_feed_customization.xml

<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"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#ffffff"
tools:context="com.shrikanthravi.newslly.FeedCustomizationFragment">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<android.support.v7.widget.RecyclerView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="10dp"
    android:paddingRight="10dp"
    android:layout_marginTop="-45dp"
    android:paddingTop="55dp"
    android:clipToPadding="false"
    android:layout_below="@+id/ll"
    android:id="@+id/CategoryRV">

</android.support.v7.widget.RecyclerView>
<android.support.v7.widget.CardView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    app:cardElevation="10dp"
    app:cardCornerRadius="20dp"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="15dp">
    <Button
        android:layout_width="wrap_content"
        android:layout_height="40dp"
        android:text="Update"
        android:visibility="gone"
        android:textAllCaps="false"
        android:textColor="@android:color/white"
        android:id="@+id/UpdateButton"
        android:background="@color/color2"/>
</android.support.v7.widget.CardView>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/ll"
        android:background="@drawable/personalize_bg_gradient"
        android:orientation="vertical">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:gravity="center"
            android:textColor="@color/color2"
            android:textSize="23sp"
            android:text="Personalize your feed"
            android:layout_marginTop="10dp"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:layout_marginBottom="8dp"
            android:layout_gravity="center"
            android:gravity="center"
            android:text="Pick at least 3 topics of your interest"/>

    </LinearLayout>

</RelativeLayout>

Пейзажная версия

frag_feed_customization.xml

<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"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#ffffff"
tools:context="com.shrikanthravi.newslly.FeedCustomizationFragment">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<android.support.v7.widget.RecyclerView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="10dp"
    android:paddingRight="10dp"
    android:layout_marginTop="-45dp"
    android:paddingTop="55dp"
    android:clipToPadding="false"
    android:layout_below="@+id/ll"
    android:id="@+id/CategoryRV">

</android.support.v7.widget.RecyclerView>
<android.support.v7.widget.CardView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    app:cardElevation="10dp"
    app:cardCornerRadius="20dp"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="15dp">
    <Button
        android:layout_width="wrap_content"
        android:layout_height="40dp"
        android:text="Update"
        android:visibility="gone"
        android:textAllCaps="false"
        android:textColor="@android:color/white"
        android:id="@+id/UpdateButton"
        android:background="@color/color2"/>
</android.support.v7.widget.CardView>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/ll"
        android:weightSum="2"
        android:background="@drawable/personalize_bg_gradient"
        android:orientation="horizontal">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:gravity="center"
            android:textColor="@color/color2"
            android:layout_weight="1"
            android:textSize="20dp"
            android:text="Personalize your feed : "
            android:layout_margin="10dp"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:layout_weight="1"
            android:textSize="20dp"
            android:layout_gravity="center"
            android:gravity="center"
            android:text="Pick at least 3 topics of your interest"/>

    </LinearLayout>

</RelativeLayout>

1 Ответ

0 голосов
/ 03 июня 2018

Просто удалите android:configChanges="orientation|keyboardHidden|screenSize"

Это мешает переопределить макет ландшафта

...