I added supportActionbar to my application using toolBar using the v7 support library. Now I need to show a custom layout in the action bar, which is just a recycle bin icon with an icon number. But when I try to do this, I get only a text button and the image does not appear. My layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="48dp" android:layout_height="fill_parent" android:layout_gravity="right" > <ImageView android:layout_width="wrap_content" android:layout_height="fill_parent" android:id="@+id/cart_img" android:clickable="true" android:src="@drawable/ic_checkout"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="3dp" android:textColor="@color/colorAccent" android:text="0" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" /> </RelativeLayout>
And I add it to the action bar using
<item android:id="@+id/ab_cart" android:icon="@drawable/ic_checkout" android:actionLayout="@layout/cart_badge" android:title="@string/action_cart" app:showAsAction="always" />
But I only get the text button "cart" in the action bar.
source share