java - Scale Action Bar background image proportionally -


im using actionbar in android app, , customize each of tabs, put background image behing actionbar, looks following:

on phone looks fine, on other phones it's squashed. how can scale actionbar proportionally based on background's ratio? there solution this? had determine height in fix dpi because if leave out, actionbar not showing up. style code following right now;

<style name="myactionbar" parent="android:theme.holo.light">      <item name="android:backgroundstacked">@drawable/tab_bg</item>     <item name="android:adjustviewbounds">true</item>     <item name="android:scaletype">fitend</item>     <item name="android:height">87dp</item>  </style> 

update:

i not know mr.t's xml code. im using basic android actionbar, , have 1 xml named menu.xml, if put code it, no effect.

i tried style actionbar following, still, if not specify android:height parameter, actionbar remains 0 , not showing up.

<style name="myactionbar" parent="android:theme.light">     <item name="android:backgroundstacked">@drawable/tab_bg</item>     <item name="android:layout_width">wrap_content</item>     <item name="android:layout_height">wrap_content</item>     <item name="android:src">@drawable/tab_bg</item>     <item name="android:scaletype">matrix</item> </style> 

the actionbar still looks following on devices; http://i.imgur.com/yqn67j3.png

you might either scaletype(http://developer.android.com/reference/android/widget/imageview.scaletype.html)

you use imageview instead of background placing first layout's element , specify android:scaletype attribute it:

 <relativelayout  android:layout_width="fill_parent"  android:layout_height="fill_parent" >  <imageview     android:layout_width="wrap_content"     android:layout_height="wrap_content"      android:src="@drawable/backgrnd"     android:scaletype="matrix" />  ...  rest layout components here  ...   </relativelayout> 

or drawable xml


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -