Bugdroid
Bugdroid

Reputation: 329

How to create buttons with semi transparent background with completely transparent text?

I want to have semitransparent buttons with fully transparent text on them. If I set text color to say #00FFFFFF and background to #33FFFFFF the text portion isn't transparent and shows background. The text has to be dynamic so I can't use an image.

Upvotes: 0

Views: 829

Answers (2)

Anbarasu Chinna
Anbarasu Chinna

Reputation: 1005

i think this is what you are trying to achieve(works with background color, not with background image)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:background="#f00"
android:orientation="vertical">

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="#88000000"
    android:gravity="center"
    android:text="TEXT TO TRANSPARENT"
    android:textColor="#f00" />

</LinearLayout>

Create a new layout file, paste the above code and click the layout "preview" button to check how it looks like.

OR

Check this link Button with background color and transparent text

Upvotes: 2

Attiq ur Rehman
Attiq ur Rehman

Reputation: 475

The reason is that you are not setting the background color of button as it supposed to be... try #07000000 for button backgroun

Upvotes: 0

Related Questions