I have an ImageView that I want locked on portrait, but a floating menu that I want to change depending on orientation. My thought was that I could just set android:orientation="vertical" in the layout xml, but this does not work as the image is still rotating.
activity_editor:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/picture"
android:scaleType="matrix"
android:src="@drawable/dotted"
android:cropToPadding="false"
android:adjustViewBounds="true"
android:orientation="vertical"/>
<com.getbase.floatingactionbutton.FloatingActionsMenu
android:id="@+id/right_labels"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="22dp"
fab:fab_addButtonColorNormal="@color/white"
fab:fab_addButtonColorPressed="@color/white_pressed"
fab:fab_addButtonPlusIconColor="@color/half_black"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="22dp">
<com.getbase.floatingactionbutton.FloatingActionButton
/>
<com.getbase.floatingactionbutton.FloatingActionButton
/>
<com.getbase.floatingactionbutton.FloatingActionButton
/>
</com.getbase.floatingactionbutton.FloatingActionsMenu>
</RelativeLayout>
Manifest:
<activity android:name=".Editor"
android:configChanges="keyboardHidden|orientation|screenSize">
</activity>
you can only lock an activity to a certain orientation. This won't be possible with a individual view.
I think your best option is to create another layout for your landscape design, you would add this to layout-land/ folder.
The view would then redraw on rotation the way you have defined it in the other layout.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.