Подтвердить что ты не робот

Позиционирование пунктов меню слева от ActionBar в Honeycomb

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

4b9b3361

Ответ 1

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

Ответ 2

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

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