I am trying to create a fullscreen activity in Android. I add the FullscreenTheme style as follows. But the action bar still shows.
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="FullscreenTheme" parent="AppTheme">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
</style>
</resources>
AndroidManifest.xml
<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/FullscreenTheme">
The project minimum SDK is API 21 Android 5.0 Lollipop.
Change Theme to this .
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
Related
To moderators: this is not a duplicate question. I've tried all avail. solutions from StackOverflow.
I've used Theme.MaterialComponents.Light.NoActionbar as a parent theme in styles.xml file.
my styles.xml:
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="android:forceDarkAllowed" tools:targetApi="q">false</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
<item name="android:navigationBarColor">#00000000</item>
<item name="snackbarStyle">#style/MySnackbar</item>
</style>
<style name="AppTheme2" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:forceDarkAllowed" tools:targetApi="q">false</item>
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:navigationBarColor">#00000000</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
<item name="snackbarStyle">#style/MySnackbar</item>
</style>
</resources>
My application class code:
public class Extendit extends Application {
#Override
public void onCreate() {
super.onCreate();
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
}
}
The application class is attached in the manifest file. Also, the AppTheme is the base theme of application.
androidmanifest.xml:
<application
android:name=".Extendit"
android:allowBackup="true"
android:appComponentFactory="df"
android:icon="#mipmap/iconx"
android:label="#string/app_name"
android:largeHeap="true"
android:roundIcon="#mipmap/iconx"
android:supportsRtl="true"
android:theme="#style/AppTheme"
tools:replace="android:appComponentFactory">
I've also added "forcedarkallowed" false flag in styles.xml and deleted the styles.xml(night) file.
P.S. I'm using Realme device.
Got the fact. The issue is with device and Realme Android 9.0 OS. It doesn't allow you to have your own day or night theme in any way, rather it forces you to have what the system is currently having.
Add this in your styles.xml file:
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="android:forceDarkAllowed" tools:targetApi="q">false</item>
</style>
And in your AppTheme use this in parent:
parent="Theme.MaterialComponents.Light.DarkActionBar"
Image error I have 2 styles files. With a click on a button I want to switch from AppTheme to AppTheme2. how to make?
Note that the primary color is with a code, colorPrymary2. That would change the color of my app completely, and that's what I want.
Manifest.xml
<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">
styles.xml
<resources>
<style name="AppTheme" parent="Theme.AppCompat">
<item name="android:windowBackground">#drawable/background</item>
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="AppTheme2" parent="Theme.AppCompat">
<item name="android:windowBackground">#drawable/background</item>
<item name="colorPrimary">#color/colorPrimary2</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
</resources>
Just do it in onCreate() method!
getApplication().setTheme(R.style.yourtheme);
I'm developing my app with SwipeBackLayout and my Activity is extends from SwipeBackActivity.The foreground activity's background is transparent when I swipe back in my devices with android api 21.But it does not work in device with api 19.
Like this:
this is the picture in device api 19
this is the picture in device api 21
and below is my style.xml in values-v19:
<!-- in values-v19 -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:windowIsTranslucent">true</item>
</style>
<style name="AppTheme2" parent="AppBaseTheme">
<item name="android:windowTranslucentStatus">true</item>
</style>
<style name="WelcomeTheme" parent="AppBaseTheme">
<item name="android:windowTranslucentStatus">false</item>
<item name="android:windowFullscreen">true</item>
</style>
and this is my style.xml in values-v21
<!-- in values-v21 -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:windowIsTranslucent">true</item>
</style>
<style name="AppTheme2" parent="AppBaseTheme">
<item name="android:windowTranslucentStatus">true</item>
</style>
<style name="WelcomeTheme" parent="AppBaseTheme">
<item name="android:windowTranslucentStatus">false</item>
<item name="android:windowFullscreen">true</item>
</style>
in manifest.xml:
<application
android:allowBackup="true"
android:name=".manager.MyApplication"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
.........
</application>
ah, I got it. because of the code below in my activity:
getWindow().setFormat(PixelFormat.RGB_565);
so the background of my Activity is not transparent.
I hope you can help me.
I created my style.xml in values-v21, so I put the theme for the entire application, but the colorPrimaryDark only works in the main activity and other activities not working.
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:theme="#style/AppTheme"
....
....
</application>
values-v21/styles.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#color/primaryDark</item>
<item name="colorAccent">#color/accent</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">#android:color/transparent</item>
<item name="android:textColorPrimary">#android:color/white</item>
<item name="colorControlNormal">#color/white</item>
</style>
I am trying to change the background color of the Popup menu in the action bar.
Everything that I try its always the same black color, that is by default.
This is what I have in my styles.xml
<style name="AppTheme" parent="Theme.AppCompat">
<item name="colorPrimary">#color/app_navbar_background</item>
<item name="colorPrimaryDark">#color/app_navbar_background</item>
<item name="colorAccent">#color/CadetBlue</item>
<item name="android:textColorSecondary">#color/black</item>
<item name="android:popupMenuStyle">#style/PopupMenu</item>
</style>
<style name="PopupMenu" parent="#android:style/Widget.PopupMenu">
<item name="android:popupBackground">#color/MediumPurple</item>
</style>
And I do have the theme set in the AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
Does anybody know what I could be doing wrong
Try using this:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat">
<!-- Customize your theme here. -->
<item name="android:itemBackground">#color/app_navbar_background</item>
</style>