ActionBar. Set custom view
Добавлено: 20 июл 2015, 18:20
Как удалить часть старого "actionbar" после setCustomView?
код java:
код custom_ab.xml
код java:
Код: Выделить всё
ActionBar actionBar = getActionBar();
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setCustomView(R.layout.custom_ab);
Код: Выделить всё
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/top_green">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ab_menu"
android:padding="10dp"
android:src="@mipmap/menu_icon" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/app_name"
android:id="@+id/textView"
android:textColor="@color/white"
android:layout_weight="1"
android:gravity="center"
android:singleLine="true"
android:layout_marginLeft="10dp" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView3"
android:src="@mipmap/search_icon"
android:padding="10dp" />
</LinearLayout>
</LinearLayout>