将菜单项定位在Honeycomb中ActionBar的左侧

Sam*_*ett 31 android android-3.0-honeycomb android-actionbar

我想在Honycomb的ActionBar左侧放置一些菜单项,但是没有找到显示如何执行此操作的文档.看起来它应该是可能的,因为联系人应用程序搜索到导航栏的左侧.有关如何将菜单项设置到左侧的任何想法?

Sam*_*ett 16

ActionBar支持应用程序图标和常规ActionBar图标之间的自定义布局.例:

// Set the custom section of the ActionBar with Browse and Search.
ActionBar actionBar = getActionBar();
mActionBarView = getLayoutInflater().inflate(R.layout.action_bar_custom, null);
actionBar.setCustomView(mActionBarView);
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
Run Code Online (Sandbox Code Playgroud)


Egi*_*gis 15

这对我来说就像梦一样:在活动中我有这个:

//hiding default app icon
ActionBar actionBar = getActionBar();
actionBar.setDisplayShowHomeEnabled(false);
//displaying custom ActionBar
View mActionBarView = getLayoutInflater().inflate(R.layout.my_action_bar, null);
actionBar.setCustomView(mActionBarView);
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM)
Run Code Online (Sandbox Code Playgroud)

my_action_bar.xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/turquoise">

    <ImageButton 
        android:id="@+id/btn_slide"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:background="@null"
        android:scaleType="centerInside"
        android:src="@drawable/btn_slide"
        android:paddingRight="50dp"
        android:onClick="toggleMenu"
        android:paddingTop="4dp"/>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)