--ADVERTISEMENT--

You can make any android view transparent background color simply using XML or java code. In this tutorial, you will learn to make transparent background in android buttons. There are many methods to create button with transparent background and here I am going to show one of the best and easiest ways to make transparent background.

Only making transparent background is not important thing, it is important that how much transparent do you need 100 percent transparent, 90 percent transparent, 40 percent transparent, 10 percent transparent etc. And which color are you going to make transparent.

Related:
Circular Button with Icon and Text in Android
Adding Border to the Top and Bottom of an Android View
Android ImageButton Example

Android Example: How to Make/Create Transparent Background of Android Button


It’s very simple just create a button where you want and add background color according to your need using background attribute like android:background="#000000" .

Now it’s time to make transparent background of android button. If you want to make 20 % transparent just add 80 at the first of your hex color code like android:background="#80000000" , if you want to make only 80 % transparent button then add 20 at the first of your hex color code like above. Similarly if you need 100% transparent background you can just use android:background="@null" or do like above.

Following is the complete modified content of XML layout file where I have added different buttons with different XML attributes to make transparent background color.

res/layout/transparent_background_android_button.xml

Following is the default code of java activity file.

src/TransparentButtonBackground.java

Android Example: How to Make/Create Transparent Background of Android Button

That’s all. Now run your Making Transparent Background of Android Button application, you will see different buttons with different transparent percent like above screenshot.

Post a Comment

Powered by Blogger.