• Set via XML file
The code is as follows |
Copy Code |
Translucent <relativelayout android:background= "#c0000000 ″...> Completely opaque <relativelayout android:background= "#ff000000 ″ .../> Fully transparent <relativelayout android:background= "#00000000 ″ .../>
|
The color and opacity (alpha) values are represented by hexadecimal notation. The range of values for any one color is 0 to 255 (00 to FF). 00 indicates full transparency, and FF represents completely opaque. The order of expressions is "AABBGGRR", where aa=alpha represents transparency, Bb=blue (00 to FF), Gg=green (00 to FF), rr=red (00 to FF).
• Set by program code
code is as follows |
copy code |
relativelayout Bottomlayout = (relativelayout) Findviewbyid (R.id.view_bottomview); //Get view by ID Bottomlayout.getbackground (). Setalpha (128); //0~255 transparency value, 0 is fully transparent, 255 is opaque |