1 |
WindowManager.LayoutParams lp=getWindow().getAttributes(); |
2 |
lp.alpha= 0 .3f; |
3 |
getWindow().setAttributes(lp); |
1 |
WindowManager.LayoutParams lp=getWindow().getAttributes(); |
2 |
lp.dimAmount= 0 .5f; |
3 |
getWindow().setAttributes(lp); |
4 |
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); |
1 |
getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND, |
2 |
WindowManager.LayoutParams.FLAG_BLUR_BEHIND); |
1
2 3 4 5 6 7 8 9 10 11 12 |
<resources>
<style name="Transparent"> <item name="android:windowBackground"> @color/transparent_background </item> <item name="android:windowNoTitle">true </item> <item name="android:windowIsTranslucent">true </item> <item name="android:windowAnimationStyle"> @+android:style/Animation.Translucent </item> </style> </resources> |
1
2 3 4 5 6 7 |
<?xml version="1.0" encoding="utf-8"?>
<resources> <color name="transparent_background">#50000000 </color> </resources> //注意: //color.xml的#5000000前兩位是透明的效果參數從00--99(透明--不怎麼透明), //後6位是顏色的設置 |
1
2 3 4 |
<activity
android:name=".TransparentActivity" android:theme="@style/Transparent"> </activity> |
1
2 3 4 5 |
public
void onCreate
(Bundle savedInstanceState
)
{
super. onCreate (savedInstanceState ) ; setTheme (R. style. Transparent ) ; setContentView (R. layout. transparent ) ; } |