4

Hello I am making an android application where I need to place a transparent view over a LinearLayout. See in the screenshot View where "04" is written is transparent but not completely. Any idea to make this view transparent with some color.

enter image description here

I made the LinearLayout with rounded and set the color also.

<LinearLayout
    android:id="@+id/thirdLinearLayout"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/secondRelativeLayout"
    android:background="@drawable/clock_check_in_rounded_drawable"
    android:orientation="horizontal" >     

</LinearLayout>

clock_check_in_rounded_drawable.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

    <solid android:color="@color/cyan_text_color" />

    <corners android:radius="10dp" />

</shape>
N Sharma
  • 33,489
  • 95
  • 256
  • 444
  • 1
    Look at Aaron's answer here [transperancy](http://stackoverflow.com/questions/1492554/set-transparent-background-of-an-imageview-in-android) – Manishika May 29 '14 at 06:49

3 Answers3

6

Before I answer your question, lets see about the html color codes:

  • Black: #000000
  • Translucent Black: ##55000000
  • Transparent Black: ##FF000000

    SO here the first two digits specify the transparency of the color.You can have values from 00 to FF for complete transparency.

amalBit
  • 12,041
  • 6
  • 77
  • 94
4

In XML set Background attribute to any colour White(#FFFFFF) shade or Black(#000000) shade.if you want transparancy just put 80 before the actual hash code.

#80000000   

If you add any number from 01 to 99 before the actual hash code, it will give you the transparency. Eg: Black with more transparency - #10000000 Black with less transparency - #99000000

Soumil Deshpande
  • 1,622
  • 12
  • 14
1

All Views in android have property Alpha , So if you want to make view fully transparent or partially transparent you can add alpha value between 0 to 1 in to alpha attribute in XML file

 <TextView
    android:text="TextView"
    android:layout_width="60dp"
    android:layout_height="60dp"
    android:background="#006549"
    android:alpha="0"
    android:id="@+id/instruction_text_view" />

OR add Alpha value to any view dynamically from java Code like below:

backButton.setAlpha(0.2F);

Chetan Joshi
  • 5,582
  • 4
  • 30
  • 43