Android/样式按钮 : Background also behind Drawable left and Drawable right

标签 android button android-layout nine-patch android-xml

我正在设计一个 Button 的样式,它的宽度可以在程序中通过不同的 Content 改变。我从设计师那里得到了这样的 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>

..

最佳答案

关于Android/样式按钮 : Background also behind Drawable left and Drawable right,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3719423/

相关文章:

android - Flutter v2.5.0 安卓闪屏

Android 按钮名称 - 它们的实际含义是什么?

android - 长按时 ActionBarImplICS(使用应用程序兼容)出现 NullPointerException

Android单选按钮文字加粗

Android 设计支持库 : TabLayout tabs text in single line

java - 在 Android 中使用 FFT

java - android - 格式化 Double 并将其放在没有逗号的 TextView 中(如果需要)

java - 使用 ADB 时 Android studio "File not found",桌面版有效

button - SweetAlert2 - 绑定(bind)另一个事件以取消按钮?

javascript - ASP.NET MVC Button.Click 不使用 javascript