简体   繁体   中英

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:

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. It allows specifying an Image and a background. Notice the src and background tags, txt is not required.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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