Расположение элементов меню слева от панели действий в Honeycomb - PullRequest
31 голосов
/ 15 марта 2011

Я хочу расположить некоторые пункты меню слева от ActionBar от Honycomb, но не нашел документации, показывающей, как это сделать. Похоже, это должно быть возможно, поскольку приложение «Контакты» выполняет поиск в левой части навигационной панели. Любая идея относительно того, как установить пункты меню на левой стороне?

Ответы [ 2 ]

16 голосов
/ 18 марта 2011

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);
15 голосов
/ 27 марта 2013

вот что работает для меня как сон: в Деятельности у меня есть это:

//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)

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>
...