首先我知道这个问题出现在此之前,但在尝试了很多之后我仍然没有成功.我从Android Developers网站开始研究这个例子 .
我正在尝试将菜单设置为从右到左打开,而不是在示例中如何实现(从左到右).此外,我想将打开菜单按钮移动到操作栏的右侧.我也在这里提出了一些答案,例如在这个答案中.
我尝试改变视图和布局的重力,但我得到错误:
没有抽屉视图发现绝对重力LEFT
你可以帮我弄清楚我的代码中有什么问题,为了设置菜单从右边打开,我应该改变什么,并将操作栏按钮移动到右侧?
xml代码在这里:
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_gravity="right"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="@+id/content_frame"
android:layoutDirection="rtl"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<ListView android:id="@+id/left_drawer"
android:layout_width="200dp"
android:layout_height="match_parent"
android:layout_gravity="right"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="10dp"
android:background="#111"/>
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)