是否有可能有在上面的文字背景图像的按钮? [英] Is it possible to have a Button with a background image with text on top?
问题描述
我需要的按钮,顶部有一个复制的背景图案和正常按钮上的文字 - 如何在布局XML指定此
I need button that has a replicated background pattern and normal button text on top - how to specify this in layout XML?
推荐答案
覆盖的android:背景
在按钮
有问题。或者,重用你可以声明自己的风格,覆盖的android:背景
从基础按钮样式:
Override android:background
on the Button
in question. Or, for reuse you could declare your own style, overriding android:background
from the base button style:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyButtonStyle" parent="Widget.Button">
<item name="android:background">@drawable/fancy_button</item>
</style>
</resources>
在这两种情况下,你的 fancy_button
绘制将是一个图像,或更可能一的 StateListDrawable
。
In either case, your fancy_button
drawable would be an image, or more likely a StateListDrawable
.
对于按钮
你希望这个申请,你会做实例:结果&LT;按钮风格=@风格/ MyButtonStyle/方式&gt;
For the Button
instances you wish to apply this to, you'd do:
<Button style="@style/MyButtonStyle" />
.
这篇关于是否有可能有在上面的文字背景图像的按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!