如何在菜单图标右侧显示菜单图标?

时间:2016-11-22 11:19:00

标签: android icons alignment android-navigationview

我有一个从右到左打开的导航抽屉,我在左侧有菜单图标,但我想要它们在右侧。如何将它们移动到菜单项的右侧?screenshot

这是我的菜单文件

OfySevice.ofy().save().entity(profile).now();

我的布局

<group android:checkableBehavior="single">

    <item

        android:id="@+id/nav_artsdesign_photography"
        android:title="Arts, Design and Photography"
        android:icon="@mipmap/ic_launcher"/>

    <item

        android:id="@+id/nav_biographies_autobiographies"
        android:title="Biographies and Autobiographies" />

    <item

        android:id="@+id/nav_comic_graphic_novels"
        android:title="Comic and Graphic Novels" />

    <item

        android:id="@+id/nav_computer_internet"
        android:title="Computer and Internet " />
    <item

        android:id="@+id/nav_history_politics"
        android:title="History and Politics" />
    <item

        android:id="@+id/nav_health_cooking"
        android:title="Health and Cooking" />
    <item

        android:id="@+id/nav_indian_writing"
        android:title="Indian Writing" />
    <item

        android:id="@+id/nav_international_books"
        android:title="International Books" />
    <item

        android:id="@+id/nav_medical"
        android:title="Medical" />
    <item

        android:id="@+id/nav_religion_spirituality"
        android:title="Religion and Spirituality" />
    <item

        android:id="@+id/nav_school_books"
        android:title="School Books" />
    <item

        android:id="@+id/nav_other"
        android:title="Other" />


</group>

请帮忙。

2 个答案:

答案 0 :(得分:0)

试试这个: 在您的xml文件中:

<android.support.design.widget.NavigationView
    android:id="@+id/navigation_view"
    android:layout_height="match_parent"
    android:layout_width="wrap_content"
    android:layout_gravity="end"
    app:headerLayout="@layout/header"
    app:menu="@menu/drawer"
    />
你的java文件中的

 @Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            if (mDrawer.isDrawerOpen(Gravity.RIGHT)) {
                mDrawer.closeDrawer(Gravity.RIGHT);
            } else {
                mDrawer.openDrawer(Gravity.RIGHT);
            }
            return true;
        case R.id.action_settings:
            return true;
    }

答案 1 :(得分:0)

将nav_drawer_row.xml更改为:

  

nav_drawer_row.xml

var form = {
    "5": {
        "480": {
            "value": []
        }
    }
};

for (var i = 0; i < 6; i++) {
    form[5][480]['value'].push(Math.floor(Math.random() * (6 - 4 + 1)) + 4);
}