2014-02-05 51 views
0

我實現導航的抽屜裏。我想從右到左。我成功地從右向左獲取抽屜列表,但操作欄圖標始終顯示在左側。我也希望它也是正確的。我怎樣才能做到這一點 ?右側導航抽屜圖標總是向左

<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:gravity="right" 
    > 

    <!-- As the main content view, the view below consumes the entire 
     space available using match_parent in both dimensions. --> 
    <FrameLayout 
     android:id="@+id/content_frame" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:baselineAligned="false" 
     /> 

    <ListView 
     android:id="@+id/left_drawer" 
     android:layout_width="240dp" 
     android:layout_height="match_parent" 
     android:layout_gravity="right" 
     android:choiceMode="singleChoice" 
     android:divider="@android:color/transparent" 
     android:dividerHeight="0dp" 
     android:background="#111"/> 
</android.support.v4.widget.DrawerLayout> 

謝謝。

+0

弄來了一個解決方案? – MRX

+0

我最終創建了自定義操作欄,其右側有一個像抽屜圖標這樣的背景圖標。點擊打開/關閉抽屜 – MSaudi

+0

謝謝,即使我也以同樣的方式結束了。不管怎麼說,多謝拉 – MRX

回答

0

兩歲,但櫃面其他人在讀這:

在您的Android清單加上此行:

android:supportsRtl="true" 

到您的應用程序,就像這樣:

<application 
android:allowBackup="true" 
android:icon="@mipmap/ic_launcher" 
android:label="@string/app_name" 
android:supportsRtl="true" 

然後在您的onCreate方法中,添加以下行:

getWindow().getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_RTL); 

警告:::只適用於SdkVersion 17+,所以如果您的應用程序的目標是較低的最低SDK,您將不得不創建一個自定義菜單並覆蓋OnCreateOptions方法(除非有另一種我不知道的方式,這絕對是可能的)。

https://developer.android.com/guide/topics/manifest/application-element.html#supportsrtl