android - Styling the Action Bar -


i'm trying style action bar adding custom button on left , icon in center. rendering in android studio want it, when test layout on phone, shows both button , icon on left, icon on top of button. layout file:

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"           android:id="@+id/action_bar_layout"     android:layout_width="match_parent"     android:layout_height="wrap_content">      <imagebutton android:id="@+id/back_button"         android:contentdescription="image"         android:src="@drawable/back_button"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_margintop="20dp"         android:background="@color/action_bar_bg_color"         android:layout_alignparentleft="true"/>      <imageview android:id="@+id/cow_icon"         android:contentdescription="image"         android:src="@drawable/cowhead"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_centerinparent="true"         android:layout_centervertical="true"/>  </relativelayout> 

and style action bar:

actionbar actionbar = getsupportactionbar();     actionbar.setdisplayshowtitleenabled(false);     view mactionbar = getlayoutinflater().inflate(r.layout.action_bar_layout, null);     actionbar.setcustomview(mactionbar);     actionbar.setdisplayshowcustomenabled(true); 

anyone see causing flawed styling of action bar?

you try using new toolbar : https://developer.android.com/reference/android/widget/toolbar.html great making custom actionbar.

otherwise, don't have make button custom, actionbar supports : https://developer.android.com/reference/android/app/actionbar.html#setdisplayhomeasupenabled(boolean)


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -