公告
财富商城
积分规则
提问
发文
2018-12-31 00:29发布
裙下三千臣
I want to create a transparent Activity on top of another activity.
How can I achieve this?
I achieved it on 2.3.3 by just adding android:theme="@android:style/Theme.Translucent" in the activity tag in the manifest.
android:theme="@android:style/Theme.Translucent"
I don't know about lower versions...
Just let the activity background image be transparent. Or add the theme in the XML file:
<activity android:name=".usual.activity.Declaration" android:theme="@android:style/Theme.Translucent.NoTitleBar" />
For dialog activity I use this:
getWindow().getDecorView().setBackgroundResource(android.R.color.transparent);
But you also need to set your main View in the activity to invisible. Otherwise the background will be invisible while all views in it will be visible.
in addition to the above answers:
to avoid android Oreo related crash on activity
<style name="AppTheme.Transparent" parent="@style/Theme.AppCompat.Dialog"> <item name="windowNoTitle">true</item> <item name="android:windowCloseOnTouchOutside">false</item> </style> <activity android:name="xActivity" android:theme="@style/AppTheme.Transparent" />
Declare your activity in the manifest like this:
<activity android:name=".yourActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"/>
And add a transparent background to your layout.
Just add the following line to the activity tag in your manifest file that needs to look transparent.
最多设置5个标签!
I achieved it on 2.3.3 by just adding
android:theme="@android:style/Theme.Translucent"
in the activity tag in the manifest.I don't know about lower versions...
Just let the activity background image be transparent. Or add the theme in the XML file:
For dialog activity I use this:
But you also need to set your main View in the activity to invisible. Otherwise the background will be invisible while all views in it will be visible.
in addition to the above answers:
to avoid android Oreo related crash on activity
Declare your activity in the manifest like this:
And add a transparent background to your layout.
Just add the following line to the activity tag in your manifest file that needs to look transparent.