开发者

Android / Styling a Button: Background also behind Drawable left and Drawable right

I am styling a Button whose width can change in the program through different Content. I got the png files from the designer like this:

[Left Border] [Background (just a strip with the gradi开发者_开发技巧ent)] [Right Border]

I thought I'm fine with assigning the Properties of the Button like this:

Background: Background.png
Drawable left: LeftBorder.png
Drawable right: RightBorder.png

BUT it shall not be like that ;) Right now the Background.png begins where the Drawable Left begins and ends at the end of Drawable Right. Is using those Drawable Properties not the right way in this case?

Here is the Code:

<Button
  android:text="@+id/Button01"
  android:id="@+id/Button01"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:drawableLeft="@drawable/top_loaction_left"
  android:drawableRight="@drawable/top_loaction_right"
  android:background="@drawable/top_loaction_bg"></Button>

..


What you need is a 9 patch image.

http://developer.android.com/guide/developing/tools/draw9patch.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜