How to make TextView Text Transparent [Android]

To make a TextView text look transparent we need to set the android:alpha attribute to it.

It has a range of 0-1,

If you set android:alpha ="0.1" the text will be 90% transparent, whereas

If you set android:alpha ="0.9" the text will appear 10% transparent (i.e. almost opaque)

You can set alpha manually in XML view, or by simply using the Properties window in the design view of Android Studio (or eclipse equivalent)

Setting alpha property
Setting alpha property
    android:text="@string/hello_world" />

✏️ Note that the alpha attribute is available from API level 11 and higher, so if you are using minSDK levels below level then you won't get any error but the application will simply ignore this attribute and you will not be able to see the effect.

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap