Android how to get AppCompat.Translucent type theme with support actionbar?
You can create a new set of styles to use which have the same properties as Theme.Translucent
from themes.xml.
Add the following to your styles.xml file:
<style name="Theme.AppCompat.Translucent"> <item name="android:windowNoTitle">true</item> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:colorBackgroundCacheHint">@null</item> <item name="android:windowIsTranslucent">true</item> <item name="android:windowAnimationStyle">@android:style/Animation</item></style>
You can change the prefix Theme.AppCompat
to something else if you want to inherit other things from the theme such as dialog styles etc. For example, a name like Theme.AppCompat.Light.Translucent
would have the properties of the Light theme.
To use the new style, set the theme property to @style/Theme.AppCompat.Translucent
<activity android:name=".TranslucentActivity" android:theme="@style/Theme.AppCompat.Translucent" ></activity>
Parama ,
<style name="Theme.AppCompat.Translucent" parent="Theme.AppCompat.NoActionBar"> <item name="android:windowNoTitle">true</item> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:colorBackgroundCacheHint">@null</item> <item name="android:windowIsTranslucent">true</item> <item name="android:windowAnimationStyle">@android:style/Animation</item> </style>
This should be the style header if you want the toolbar to disappear.you can use any parent theme which has NoActionBar for other effects.
Hope this helps
If we use Translucent for transparent activity.It raises other issues - the color of Msgbox (now white previously black), Default dialog color, the spinners do drop down but do not show the underline and drop-down arrow. The spinners are color black text black; drop-down white drop-down text black and etc.To overcome this problem, you can just use below code
In style
<style name="Theme.AppCompat.Transparent.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar"> <item name="android:windowIsTranslucent">true</item> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowContentOverlay">@null</item> <item name="android:windowNoTitle">true</item> <item name="android:windowIsFloating">false</item> <item name="android:backgroundDimEnabled">false</item></style>
In manifest file
<activity android:name=".activity.YourActivityName" android:theme="@style/Theme.AppCompat.Transparent.NoActionBar" />
I hope it will helpThanks