Activity not transparent while using Theme.AppCompat - android

I have tried lots of to make activity or main layout transparent using theme defined into style.xml with different different attribute in theme still not working.
Only view.setalpha(0) that makes layout or activity is transparent, but how to possible through style.xml. I am using Theme.AppCompact for support lower version of Android device.
Also i have tried lots of SO answer but none of one is working. What i am doing wrong or any correction there? what I have done so far is as following.
Please help me to solve the issue.
style.xml
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="Theme.AppCompat.Translucent" parent="AppTheme">
<item name="android:background">#android:color/transparent</item> <!-- Or any transparency or color you need -->
<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:windowContentOverlay">#null</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowAnimationStyle">#android:style/Animation</item>
</style>
</resources>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="demo.intel.com.serviceprogressbarnotification">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:theme="#style/Theme.AppCompat.Translucent">
</activity>
<activity android:name=".TestActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

Well I have same case but I wanted to make my window to act like dialog and on the background of it I put my required transparency level. here is the style I used:
<style name="transparent_alertDialog" parent="Theme.AppCompat.Dialog.Alert">
<item name="windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:backgroundDimAmount">0.95</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowMinWidthMajor">50%</item>
<item name="android:windowMinWidthMinor">50%</item>
<item name="android:windowContentOverlay">#null</item>
<item
name="android:windowAnimationStyle">#android:style/Animation.Dialog</item>
<item name="android:windowCloseOnTouchOutside">false</item>
</style>
and in manifest I used it like :
<activity
android:name=".PaymentConfirmationActivity"
android:label=""
android:theme="#style/transparent_alertDialog"
android:windowSoftInputMode="adjustPan"/>
So it did the trick for me.
Hope so it will help for you too.

Related

I have removed the action bar for a specific activity and it is still showing in the preview

I have removed the action bar for a specific activity and it is working perfectly and the action bar is removed when I run the app on Emulator/Device but the problem is that it is still showing in the preview. Due which It affects my design.
Here is my style file where I set the noAction bar:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<!-- Text Styles -->
<style name="textStyle">
<item name="android:textColor">#color/theme_color</item>
<item name="android:textSize">16sp</item>
</style>
<style name="textStyle.tagline">
<item name="android:textAllCaps">true</item>
<item name="android:textSize">46sp</item>
</style>
<!-- Button Styles -->
<style name="button_transparent">
<item name="android:textAllCaps">true</item>
<item name="android:textColor">#color/theme_color</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
</style>
<style name="button_blue">
<item name="android:textAllCaps">true</item>
<item name="android:textColor">#color/white</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
</style>
</resources>
I have also applied that style on activities as shown here:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.eapple.karumber">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".Splash_Screen" android:theme="#style/AppTheme.NoActionBar"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".protips_activity" android:theme="#style/AppTheme.NoActionBar"></activity>
</application>
</manifest>
But is still showing in the preview as shown here:
Android Studio preview
Fastest solution:
Open your activity's XML.
Switch to the design tab.
On the upper part of the design tab click on AppTheme.
Choose your new theme (the one with no action bar).
However
Adding this line to the activity XML root view should automatically reference to the same activity theme set in AndroidManifest
tools:context=".YourActivityName"
If this is only on the preview u can change the theme with an option on the top of the view. Just select you theme with NoActionBar

Change AppTheme dynamically

Goal: I want to allow user to change the color theme of my app.
Themes (styles.xml):
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/indigoColorPrimary</item>
<item name="colorPrimaryDark">#color/indigoColorPrimaryDark</item>
<item name="colorAccent">#color/indigoColorAccent</item>
<item name="android:statusBarColor">#color/indigoColorPrimaryDark</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.FullScreen">
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
</style>
<style name="AppTheme.MainActivity">
<item name="android:statusBarColor">#android:color/transparent</item>
</style>
<style name="AppTheme.SearchActivity">
<item name="android:statusBarColor">#android:color/darker_gray</item>
<item name="android:windowAnimationStyle">#null</item>
</style>
<!-- Colors -->
<style name="AppTheme.Indigo">
<item name="colorPrimary">#color/indigoColorPrimary</item>
<item name="colorPrimaryDark">#color/indigoColorPrimaryDark</item>
<item name="colorAccent">#color/indigoColorAccent</item>
<item name="android:statusBarColor">#color/indigoColorPrimaryDark</item>
</style>
<style name="AppTheme.Blue">
<item name="colorPrimary">#color/blueColorPrimary</item>
<item name="colorPrimaryDark">#color/blueColorPrimaryDark</item>
<item name="colorAccent">#color/blueColorAccent</item>
<item name="android:statusBarColor">#color/blueColorPrimaryDark</item>
</style>
<style name="AppTheme.Red">
<item name="colorPrimary">#color/redColorPrimary</item>
<item name="colorPrimaryDark">#color/redColorPrimaryDark</item>
<item name="colorAccent">#color/redColorAccent</item>
<item name="android:statusBarColor">#color/redColorPrimaryDark</item>
</style>
<!-- some other colors -->
</resources>
As you can see, I have the main theme AppTheme that as a default color ("indigo").
I have three other themes FullScreen, MainActivity and SearchActivity that derive from AppTheme, and then colors themes.
AndroidManifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.superbstudios.reportnote">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".SignInActivity"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.FullScreen" />
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SearchActivity"
android:label=""
android:theme="#style/AppTheme.SearchActivity"
android:windowSoftInputMode="stateVisible" />
<activity
android:name=".SettingsActivity"
android:label="#string/title_activity_settings"
android:theme="#style/AppTheme" />
<activity
android:name=".GuideActivity"
android:label="#string/title_activity_guide"
android:theme="#style/AppTheme" />
</application>
</manifest>
Now, only SignInActiviy, MainActivity and SearchActivity has their own themes, the other activity (also application) has AppTheme.
What I do: I create a BaseActivity class, and all activity extend this class.In BaseActivity in onCreate method before super declaration I use this code to change color theme:
setTheme(R.style.AppTheme_Red);
Problem: This code change the theme for all activity and also for SignInActiviy, MainActivity and SearchActivity that needs a different theme.
I don't know if the colors theme are useful.
The only things i want is to change the AppTheme colors like this:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/redColorPrimary</item>
<item name="colorPrimaryDark">#color/redColorPrimaryDark</item>
<item name="colorAccent">#color/redColorAccent</item>
<item name="android:statusBarColor">#color/redColorPrimaryDark</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
So, what I have to do to change colors of my app?
I solved it by changing styles.xml
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/indigoColorPrimary</item>
<item name="colorPrimaryDark">#color/indigoColorPrimaryDark</item>
<item name="colorAccent">#color/indigoColorAccent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.FullScreen">
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
</style>
<style name="AppTheme.MainActivity">
<item name="android:statusBarColor">#android:color/transparent</item>
</style>
<style name="AppTheme.SearchActivity">
<item name="android:statusBarColor">#android:color/darker_gray</item>
<item name="android:windowAnimationStyle">#null</item>
</style>
<!-- Colors -->
<style name="Indigo">
<item name="colorPrimary">#color/indigoColorPrimary</item>
<item name="colorPrimaryDark">#color/indigoColorPrimaryDark</item>
<item name="colorAccent">#color/indigoColorAccent</item>
</style>
<style name="Blue">
<item name="colorPrimary">#color/blueColorPrimary</item>
<item name="colorPrimaryDark">#color/blueColorPrimaryDark</item>
<item name="colorAccent">#color/blueColorAccent</item>
</style>
<style name="Red">
<item name="colorPrimary">#color/redColorPrimary</item>
<item name="colorPrimaryDark">#color/redColorPrimaryDark</item>
<item name="colorAccent">#color/redColorAccent</item>
</style>
</resources>
And in my BaseActivity i use this code:
getTheme().applyStyle(R.style.Blue, true);
Referenced to the comment
I'll answer by taking Red color as an example
If you only want to change the colorPrimary then keep only it.
<style name="AppTheme.Red">
<item name="colorPrimary">#color/redColorPrimary</item>
</style>
Other wise create two themes for Red color. One with status bar color and other inheriting that with transparent status bar.
<style name="AppTheme.Red">
<item name="colorPrimary">#color/redColorPrimary</item>
<item name="colorPrimaryDark">#color/redColorPrimaryDark</item>
<item name="colorAccent">#color/redColorAccent</item>
<item name="android:statusBarColor">#color/redColorPrimaryDark</item>
</style>
<style name="AppTheme.RedTransparentStatus" parent="AppTheme.Red>
<item name="android:statusBarColor">#android:color/transparent</item>
</style>
So if you want status bar to transparent you can set the second theme or else the first.
From my understanding, you want to keep the default "Indigo" color for
SignInActivity, MainActivity, SearchActivity.
Todo so inherit the relevant themes of those activities with AppTheme
<style name="AppTheme.SearchActivity" parent="AppTheme">
...
</style>

ActionBar and title not dissapearing after changes to AndroidManifest.xml and styles.xml in nativescript

Here is my AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.domain.project"
android:versionCode="1"
android:versionName="1.0">
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"/>
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="25"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:name="com.tns.NativeScriptApplication"
android:allowBackup="true"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<activity
android:name="com.tns.NativeScriptActivity"
android:label="#string/title_activity_kimera"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="#style/LaunchScreenTheme">
<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="#style/AppTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.tns.ErrorReportActivity"/>
</application>
</manifest>
And here is my values/styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<!-- theme to use FOR launch screen-->
<style name="LaunchScreenThemeBase" parent="Theme.AppCompat.Light.NoActionBar">
<!--<item name="toolbarStyle">#style/NativeScriptToolbarStyle</item>-->
<item name="colorPrimary">#color/ns_primary</item>
<item name="colorPrimaryDark">#color/ns_primaryDark</item>
<item name="colorAccent">#color/ns_accent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowBackground">#drawable/splash_screen</item>
<item name="android:windowActionBarOverlay">false</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
<style name="LaunchScreenTheme" parent="LaunchScreenThemeBase">
</style>
<!-- theme to use AFTER launch screen is loaded-->
<style name="AppThemeBase" parent="Theme.AppCompat.Light.NoActionBar">
<!--<item name="toolbarStyle">#style/NativeScriptToolbarStyle</item>-->
<item name="colorPrimary">#color/ns_primary</item>
<item name="colorPrimaryDark">#color/ns_primaryDark</item>
<item name="colorAccent">#color/ns_accent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">false</item>
<item name="android:windowContentOverlay">#null</item>
</style>
<style name="AppTheme" parent="AppThemeBase">
</style>
<!-- theme for actioon-bar
<style name="NativeScriptToolbarStyleBase" parent="Widget.AppCompat.Toolbar">
<item name="android:background">#color/ns_primary</item>
<item name="theme">#style/ThemeOverlay.AppCompat.ActionBar</item>
<item name="popupTheme">#style/ThemeOverlay.AppCompat</item>
</style>
<style name="NativeScriptToolbarStyle" parent="NativeScriptToolbarStyleBase">
</style> -->
</resources>
I can change values in android:windowFullscreen and the app goes fullscreen or not, accordingly to the boolean set. So, I know that the manifest file is being parsed correctly. However, the title bar / action bar / toolbar is simply never hiding and always appears with the app in the title.
I am using this angular seed, not sure if relevant: https://github.com/TeamMaestro/angular-native-seed
I've been stuck in this for some time now, can someone help? Thanks :)
I can change values in android:windowFullscreen and the app goes
fullscreen or not, accordingly to the boolean set. So, I know that the
manifest file is being parsed correctly. However, the title bar /
action bar / toolbar is simply never hiding and always appears with
the app in the title.
Your manifest is correct, but your preview is set up wrong. You have to remember that the Android Studio preview doesn't reflect how your application will actually look when run on a real device.
I created a dummy project to explain. Here is code that removes the action bar, similar to what you have:
android:theme="#style/Theme.AppCompat.Light.NoActionBar">
Which looks like this in source code:
<style name="Theme.AppCompat.Light.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
Now this clearly tells the app to not show an action bar, just like your theme does. However, if you look at the preview, you will see this:
So then how do you make your preview accurately reflect your theme? Well, click here:
And adjust your theme to include no action bar!
As a result, you have no action bar in the preview and in the application:
Let me know if this was helpful!
i Go Through Your Code and havent found any Problem ,But Maybe There is issue with code but U can Try Compare with This style that works for me:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
Add this code to style.xml
<style name="AppTheme.NoActionBar.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
and add this code to AndroidManifest.xml
<activity
android:name="com.tns.NativeScriptActivity"
android:label="#string/title_activity_kimera"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="#style/AppTheme.NoActionBar.NoActionBar">
<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="#style/AppTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.tns.ErrorReportActivity"
android:theme="#style/AppTheme.NoActionBar.NoActionBar"/>
Try this in your styles.xml
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<!-- Customize your theme here. -->

colorprimarydark only work for the mainactivity,what should i do with it

this is my manifest
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:supportsRtl="true"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<service android:name="com.amap.api.location.APSService" />
<activity
android:name=".MainActivity"
android:label=""/>
<activity
android:name=".QueryActivity"
android:label="" />
<activity
android:name=".LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".RegistActivity" />
<activity
android:name=".TaskListActivity"
android:label="" />
<activity
android:name=".TaskWatcherActivity"
android:label="" />
<activity
android:name=".DetailsActivity"
android:label="" />
</application>
i have set the style in style:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="drawerArrowStyle">#style/DrawerArrowStyle</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="colorControlNormal">#color/cpb_white</item>
</style>
<style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle">
<item name="spinBars">true</item>
<item name="color">#android:color/white</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
&style-v21:
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:fitsSystemWindows">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:navigationBarColor">#android:color/transparent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
<item name="android:textSize">15sp</item>
<item name="android:colorControlNormal">#color/cpb_white</item>
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="drawerArrowStyle">#style/DrawerArrowStyle</item>
</style>
but only the mainactivity's status bar is in colorprimarydark,other activities' statusbar is in the color of their layout's background. so how can i make colorprimarydark work for every activity's status bar
Very easy and useful library for Tint Color use this library in every Activity set you status color.
Try to Use android:theme="#style/AppTheme" in each and every activity.
I think you solve your problem.
finally, i used the library for Tint Color to solve the problem, p.s.thasks to Jhaman Das.
And i found that the attr of statusBarColor would cover the effect of colorpromarydark, it is the drawlayout that can have the ideal effect. willing to get further discussion on this problem.

How to create trasparent activity when i click Floating action button

First sorry for my bad English ,I am creating activity within that activity , i create floating action button ,when i click Floating Action Button on click action i show one activity it working fine but how to change my activity to transparent activity with no action bar
i change manifest file but getting some errors
mainifest file
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".FullscreenActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/title_activity_fullscreen"
android:theme="#style/FullscreenTheme" >
</activity>
<activity
android:name="com.aa.bunny.aabunny.Main2Activity"
android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen" >
</activity>
<activity
android:name=".ScrollingActivity"
android:label="#string/title_activity_scrolling"
android:theme="#style/AppTheme.NoActionBar" >
</activity>
<activity android:name=".Main22Activity" >
</activity>
</application>
Style.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="FullscreenTheme" parent="AppTheme">
<item name="android:actionBarStyle">#style/FullscreenActionBarStyle</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowBackground">#null</item>
<item name="metaButtonBarStyle">?android:attr/buttonBarStyle</item>
<item name="metaButtonBarButtonStyle">?android:attr/buttonBarButtonStyle</item>
</style>
<style name="FullscreenActionBarStyle" parent="Widget.AppCompat.ActionBar">
<item name="android:background">#color/black_overlay</item>
</style>
<style name="Transparent" parent="android:Theme">
<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">true</item>
<item name="android:backgroundDimEnabled">false</item>
Change activity theme to achieve transparency.
create a style like this
<style name="Theme.Transparent" parent="android:Theme">
<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">true</item>
<item name="android:backgroundDimEnabled">false</item>
and use this in manifest
<activity android:name=".TransparentActivity" android:theme="#style/Theme.Transparent">
Happy coding...
You can apply theme like..
android:theme="#android:style/Theme.Translucent"
Or else you can also create your own theme in style..
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Transparent" parent="android:Theme">
<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">true</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
</resources>
You can also Set background of the activity as a transparent png image or a transparent color code

Categories

Resources