2016-10-05 60 views
0

我有一個ImageView,我想在肖像上鎖定,但是我想根據方向更改一個浮動菜單。我的想法是,我可以在佈局xml中設置android:orientation =「vertical」,但這不起作用,因爲圖像仍在旋轉。在Android中將imageview鎖定到肖像模式中

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> 

清單:

<activity android:name=".Editor" 
     android:configChanges="keyboardHidden|orientation|screenSize"> 
</activity> 

回答

1

你只能鎖定一個活動有一定的方向。這是不可能的,一個人的看法。

我認爲你最好的選擇是爲你的景觀設計創建另一個佈局,你可以把它添加到layout-land /文件夾中。

然後該視圖會按照您在其他佈局中定義的方式重新繪製旋轉。

+0

所以'android:orientation =「vertical」'工作後我創建一個土地文件或我需要做的代碼? – Mardymar

+0

您不需要設置方向。 UI將簡單地遵循每個xml中定義的方向 –

相關問題