如何在设备屏幕右侧设置“抽屉布局"图标? [英] how to set Drawer Layout icon in right side of the device screen?

查看:167
本文介绍了如何在设备屏幕右侧设置“抽屉布局"图标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了抽屉布局示例应用程序,它工作正常,我的问题是抽屉布局在右到左完美地工作,但是我试图将图标从左侧移到右侧,但是它不能正常工作,请给我您的建议. !这有可能吗?

I have created drawer layout sample application, it's working fine, my problem is drawer layout working in right to left perfectly but I am trying to move icon left side to right side but it's not working give me your suggestion..!!! This is possible or not?

<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:layout_gravity="right" >

    <!-- The main content view -->

    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
         />
    <!-- The navigation drawer -->

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

</android.support.v4.widget.DrawerLayout>

推荐答案

此图标表示导航菜单,根据设计,该菜单必须位于屏幕的左侧.根据指南,尽管我们可以在右侧有一个导航抽屉,但是该导航抽屉将用于修改内容(例如过滤器).为此,您可能需要使用ActionbarItem,并在屏幕的右上角放置一个ActionItem.单击该操作项将打开或关闭右侧的导航抽屉.

This icon represents navigation menu, which by design has to be on left side of the screen. As per the guidelines, we can although have a navigation drawer on right side, but that shall be used to modify the contents (for example filters). For all such purposes you might want to use ActionbarItem, and put up an ActionItem in right corner of the screen. Click on that action item will open or close the right navigation drawer.

但是可以肯定的是,按照设计,这个动画的三行菜单图标代表导航,应该位于左侧.

But for sure, as per the design, this animated three lined menu icon, which represents navigation shall be on left hand side.

仅供参考,要将导航抽屉放在右侧,您必须按以下方式更改导航抽屉的重力:

Just for the information, to put the navigation drawer on right side, you have to change the gravity of navigation drawer as follows:

    <?xml version="1.0" encoding="utf-8"?>
<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:background="@color/main_background" >

    <!-- The main content view -->

    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    </FrameLayout>
    <!-- The navigation drawer -->

    <LinearLayout
        android:id="@+id/right_drawer"
        android:layout_width="280dp"
        android:layout_gravity="end"
        android:layout_height="match_parent"
        android:orientation="vertical" />

</android.support.v4.widget.DrawerLayout>

此外,在这种情况下,您确实希望导航菜单图标在右侧,使用自定义标题布局或使用ActionBarSherlock之类的库进行编辑.

Also, in this case you really really want the navigation menu icon, on right either use custom header layouts or a library like ActionBarSherlock to edit it.

我希望这会有所帮助!

这篇关于如何在设备屏幕右侧设置“抽屉布局"图标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆