简体   繁体   English

带有透明文字的Android按钮

[英]Android button with transparent text

I have a button on an image. 我在图像上有一个按钮。 I would like to have this button with a solid background color and transparent text (to display the back image). 我希望这个按钮具有纯色背景和透明文本(以显示背面图像)。 Is it possible to make it have only transparent text? 是否可以使它只有透明文字?

Try adding these attributes to your Button: 尝试将这些属性添加到Button:

android:textColor="@android:color/transparent"
android:background="@android:color/black"

By transparent do you mean like partially visible. 通过透明你的意思是部分可见。 Also look into the image button instead of assigning the background image to a button. 同时查看图像按钮,而不是将背景图像指定给按钮。

This sounds like it may be a use case for an ImageButton. 这听起来像是ImageButton的用例。 It allows specifying an Image and a background. 它允许指定图像和背景。 Notice the src and background tags, txt is not required. 注意src和background标签,不需要txt。

<ImageButton
    android:id="@+id/imageBtn"
    android:layout_width="@dimen/btn_large_len"
    android:layout_height="@dimen/btn_large_len"
    android:src="@drawable/ic_action_play"
    android:background="@drawable/btn_gray" >
</ImageButton>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM