Android设置Activity背景为透明style
16lz
2021-12-04
方法一:
通过Theme.Translucent
@android:style/Theme.Translucent@android:style/Theme.Translucent.NoTitleBar@android:style/Theme.Translucent.NoTitleBar.Fullscreen
只需要在Manifest中需要透明的Activity内设置theme为以上任意一个就可以了
<activityandroid:name="com.vixtel.simulate.MainApp"android:configChanges="keyboardHidden|orientation"android:label="@string/app_name"android:screenOrientation="portrait"android:theme="@android:style/Theme.Translucent.NoTitleBar"><intent-filter><actionandroid:name="android.intent.action.MAIN"/><categoryandroid:name="android.intent.category.LAUNCHER"/></intent-filter></activity>
方法二:
自定义style,就像自定义Dialog的style一样,在res-values-color.xml中添加透明颜色值:
<?xmlversion="1.0"encoding="UTF-8"?><resources><colorname="transparent">#0000</color></resources>
在res-values-styles.xml中添加如下:
<stylename="myTransparent"><itemname="android:windowBackground">@color/transparent</item><itemname="android:windowNoTitle">true</item><itemname="android:windowIsTranslucent">true</item><itemname="android:windowAnimationStyle">@android:style/Animation.Translucent</item></style>
在Manifest中中需要透明的Activity内设置theme为我们自定义的即可
android:theme="@style/myTransparent"
更多相关文章
- android sd卡读取数据库
- Android(安卓)设置圆角背景
- 设置Textview最大长度,超出显示省略号
- 【Android】编译CM10.1遇到的错误解决方案
- Android(安卓)应用程序请求Vsync
- android 模拟器上网 设置
- ImageView属性中android:src和android:background有什么区别
- android 透明效果
- Android(安卓)layout属性大全