1

我正在设计一个按钮,其宽度可以通过不同的内容在程序中改变。我从设计师那里得到了这样的 png 文件:

[Left Border] [Background (just a strip with the gradient)] [Right Border]

我想我可以像这样分配按钮的属性:

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

但它不应该是这样的;)现在 Background.png 从 Drawable Left 开始的地方开始,并在 Drawable Right 的末尾结束。在这种情况下,使用那些 Drawable 属性不是正确的方法吗?

这是代码:

<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>

..

4

1 回答 1

3

您需要的是 9 个补丁图像。

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

于 2010-09-15T15:58:57.023 回答