android 透明activity

1.colors.xml里定义<color name="transparent_background">#A0000000</color>
2.styles.xml里定义
    <style
        name="prompt_style">
         <item name="android:windowBackground">@color/transparent_background</item>  
         <item name="android:windowIsTranslucent">true</item>
         <item name="android:windowNoTitle">true</item>
         <item name="android:windowAnimationStyle">@+android:style/Animation.Translucent</item>
    </style>
3.在mainfest里的activity里配android:theme="@style/prompt_style"
4.在activity里写
		Window window = getWindow();
		WindowManager.LayoutParams layoutParams = window.getAttributes();
		layoutParams.flags = WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
		layoutParams.alpha = 0.5f;//透明度
		window.setAttributes(layoutParams);

你可能感兴趣的:(android)