Android / 按钮样式:背景也在 Drawable left 和 Drawable right 后面

发布于 2024-09-24 01:31:14 字数 774 浏览 2 评论 0原文

我正在设计一个按钮,其宽度可以在程序中通过不同的内容进行更改。我从设计师那里得到了这样的 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 开始和结束的地方开始在可绘制权利的末尾。在这种情况下使用这些可绘制属性不是正确的方法吗?

这是代码:

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

..

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 gradient)] [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>

..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文