Android设置Activity背景为透明style
Android 设置 背景 Activity 透明 Style
2023-09-11 14:18:00 时间
方法一:
通过Theme.Translucent
@android:style/Theme.Translucent
@android:style/Theme.Translucent.NoTitleBar
@android:style/Theme.Translucent.NoTitleBar.Fullscreen
只需要在Manifest中需要透明的Activity内设置theme为以上任意一个就可以了
<activity
android: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>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
方法二:
自定义style,就像自定义Dialog的style一样,在res-values-color.xml中添加透明颜色值:
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<color name="transparent">#0000</color>
</resources>
在res-values-styles.xml中添加如下:
<style name="myTransparent">
<item name="android:windowBackground">@color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">@android:style/Animation.Translucent</item>
</style>
在Manifest中中需要透明的Activity内设置theme为我们自定义的即可
android:theme="@style/myTransparent"
运行程序后,就全透明了,看得见背景下的所有东西可以却都操作无效。
相关文章
- Android开发之视图动画基础
- 安卓 android studio 报错 The specified Android SDK Build Tools version (27.0.3) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle
- JAVA Eclipse开发Android如何设置滚动条最大值最小值
- 《android开发艺术探索》读书笔记(十五)--Android性能优化
- Android -- 面试 -- 数据库升级策略
- Android--百度地图开发(二)
- android -7.1去掉设置中的位置信息选项
- Android 11.0 设置默认Launcher安装一款Launcher默认Launcher无效的解决方案
- Android 9.0 cache目录下恢复出厂设置不会被删除的文件的修改
- Android 9.0 recovery 菜单页跳过弹窗自动 WIPE_DATA(恢复出厂设置)
- 【Android 电量优化】电量优化 ( Battery Historian 环境要求 | 电量分析报告 | 电量优化三原则 | 电量优化注意事项 )
- android BaseFragment获取Context上下文方法
- Android Studio设置打开文件标签多行排列显示
- android 快速入门kotlin