Android support Toolbar not displaying custom drawable properly -
i'm trying update apps actionbar toolbar encountered problem on customizing toolbar display custom drawable.
what tried far set xml drawable toolbar destroys whole toolbar , moved menu button down cannot see it:
here's drawable first:
bg_actionbar.xml
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item android:drawable="@drawable/bg_gradient" /> <item android:drawable="@drawable/icon_logo" /> </layer-list>
bg_gradient 9patch image gradient , same icon_logo.
and toolbar:
<android.support.v7.widget.toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/actionbar" android:layout_width="match_parent" android:layout_height="?attr/actionbarsize" android:background="@drawable/bg_actionbar" app:contentinsetend="0dp" app:contentinsetstart="0dp"> </android.support.v7.widget.toolbar>
this 1 pushes menu button below , has spacing of 300dp on left icon shrinked in height.
now tried directly changed background straight png image (bg_gradient) , same thing happens. i've tried adding imageview inside toolbar same thing destroys whole toolbar , once again i'm lost on how can customize toolbar further. has idea? tia.
update:
i tried adding linear layout on toolbar contain background still doesn't display on end:
<android.support.v7.widget.toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/actionbar" android:layout_width="match_parent" android:layout_height="?attr/actionbarsize" android:background="@color/cherry_red" app:contentinsetend="0dp" app:contentinsetstart="0dp"> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/bg_actionbar"/> </android.support.v7.widget.toolbar>
here's happened:
additionally here's expected be:
icon should on center, , 9patch image gradient since i'm having trouble on xml have percentage on start mid , end colors , navigationicon should on top of gradient.
hey think helps because have app similar
my xml so:
<android.support.v7.widget.toolbar xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/custom_toolbar" android:layout_width="match_parent" android:layout_height="56dp" android:background="@drawable/actionbar_bg" > <relativelayout android:id="@+id/toolbar_logo" android:layout_width="140dp" android:layout_height="40dp" android:background="@drawable/ic_logo" android:layout_gravity="left|center_vertical" android:clickable="true"> </relativelayout> </android.support.v7.widget.toolbar>
while drawable/actionbar_bg so:
<?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item> <shape android:shape="rectangle"> <gradient android:startcolor="#ffffff" android:endcolor="#4093a3" android:angle="90" /> </shape> </item> </layer-list>
hope helps you.
Comments
Post a Comment