English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Method 1:
Through Theme.Translucent
@android:style/Theme.Translucent @android:style/Theme.Translucent.NoTitleBar @android:style/Theme.Translucent.NoTitleBar.Fullscreen
Only set the theme to any of the above in the transparent Activity that is needed in the Manifest
<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>
Method Two:
Custom style, just like custom Dialog style, in res-values-color.xml, add the transparent color value:
<?xml version="1.0" encoding="UTF-8"?> <resources> <color name="transparent">#0000</color> </resources>
In res-values-Add the following to 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>
In the Manifest, set the theme of the Activity that needs to be transparent to our custom theme
android:theme="@style/myTransparent"
After running the program, it becomes completely transparent, and everything under the background can be seen, but all operations are invalid.
This is the full content of the simple method brought to you by the editor to set the background of the Android setting Activity to transparent style (must read). Hope everyone will support and cheer for the tutorial~