当前位置: 动力学知识库 > 问答 > 编程问答 >

android - action bar menu - move icons to the right side

问题描述:

I added icons to the action bar's submenu items , but the icons appear in the left side, and I want them to appear in the right side.

screenshot:

Code :

 <menu>

<item android:id="@+id/item6" android:title="יועצת וירטואלית" android:icon="@drawable/chaticon"></item>

<item android:id="@+id/item1" android:title="מעקב" android:icon="@drawable/iconinfo"></item>

</menu>

网友答案:

You mean the navigation drawer, You can customize the navigation drawer fully see a video tutorial here source code is also given.

You only have to change custom_drawer_item.xml file with this code.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <LinearLayout
      android:id="@+id/itemLayout"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true"
      android:orientation="vertical"

      android:layout_marginTop="0dp"
      android:background="?android:attr/activatedBackgroundIndicator"
     >

              <LinearLayout

                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  android:minHeight="55dp"
                 >


                  <TextView
                      android:id="@+id/drawer_itemName"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      android:textAppearance="?android:attr/textAppearanceLarge"
                      />

                  <ImageView
                      android:id="@+id/drawer_icon"
                      android:layout_width="wrap_content"
                      android:layout_height="wrap_content"
                      />


              </LinearLayout>

               <View
      android:layout_width="match_parent"
      android:layout_height="1dp"
      android:layout_marginBottom="1dp"
      android:layout_marginTop="1dp"
      android:layout_marginLeft="10dp"
      android:layout_marginRight="10dp"
      android:background="#DADADC"

       ></View>

    </LinearLayout>

</RelativeLayout>
网友答案:

Try

android:orderInCategory="2"

for the first item and

android:orderInCategory="1"

This may put the items in order, thus allowing the configuration that you described.

网友答案:

You need to create a custom view and set that as the action view for the specific menu item(s) you want to change. Please refer to this post: http://stackoverflow.com/a/17333227/1134429

网友答案:

If you really want to do this, you can use popuwindow and custom a menu view.But I suggest you just let the icon placed left, because it's the design of google and it is standard.

分享给朋友:
您可能感兴趣的文章:
随机阅读: