I want the background of the system bars to match the theme background in both light and dark mode. As such, I have the following in my values-v27/styles.xml:
<style name="Theme.SystemBarColors" parent="Theme.AppCompat.DayNight.NoActionBar">
<item name="android:statusBarColor">?android:attr/colorBackground</item>
<item name="android:windowLightStatusBar">?attr/isLightTheme</item>
<item name="android:navigationBarColor">?android:attr/colorBackground</item>
<item name="android:windowLightNavigationBar">?attr/isLightTheme</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowTranslucentNavigation">false</item>
<item name="android:windowTranslucentStatus">false</item>
</style>
My app theme then has that as a parent. This seems to work fine on all relevant Android versions by itself.
However, I also want to disable the exit animation on the OS-provided splash screen. (The OS-provided splash hides to reveal an identical-looking splash screen that our app displays on all Android versions while Chrome is launching to show our TWA, so the exit animation makes the hand off look odd and less seamless.) To disable the exit animation, I call this in onCreate on Android 12+:
getSplashScreen().setOnExitAnimationListener(SplashScreenView::remove);
This works to disable the animation, but has the unfortunate side effect on Android 12 and 12L of also causing windowLightStatusBar and windowLightNavigationBar no longer to take effect. statusBarColor and navigationBarColor are still applied, however, leading to an unfortunate white-on-almost-white appearance for the bars. This only happens in situations where the OS-provided splash is actually displayed. E.g., launch from Android Studio → no OS-splash → windowLight*Bar applied versus launch from home screen → OS-splash displayed → windowLight*Bar not applied.
In contrast windowLight*Bar does appear to be applied in both cases on Android 13, so I'm not sure if I'm doing something wrong or if this is just an Android bug that was later fixed. However, even in the latter case, I'd appreciate any help finding a workaround that allows windowLight*Bar to be applied on 12 and 12L while still allowing a seamless handoff between the two identical-looking splash views.
Related
Please notice that there is a mid-GREY banner above the app. How can I
Remove this (the app should ideally begin right below 9:56)
Change the background color (less ideal)
TLDR;
It's a display bug on the Pixel 4 emulator. Real Pixel 4 doesn't have that gap.
Edit
My answer below was not spot on. I tried on an emulated Pixel 4, API 29 (with Android Studio 4.2, macOS Big Sur) with rounded corners, as yours, and it rather seems to be an issue with the curve of the phone than an empty ActionBar.
My app on a pixel 4:
Even Youtube has this space:
Edit 2
Compared with a real Pixel 4
We clearly see that this gigantic gap is only on the emulator.
That's a bug on the emulator, and probably the main reason why no one talks about it around the web (googling Pixel 4 status bar height shows angry Pixel 5 owners results about its huge height).
Didn't found any bug report about it, I'll file one.
Old answer
What you see is probably an empty ActionBar, that has the same color of your StatusBar.
If you use the default theme, your app will use it :
Beginning with Android 3.0 (API level 11), all activities that use the default theme have an ActionBar as an app bar.
It displays your Application's name, defined in your MainApplication's android:label on your AndroidManifest.xml (or MainActivity's if not found). As it's empty, there's just an empty space displayed.
As you manage your own navbar, you can disable with the base theme of your choice Theme.AppCompat.*.NoActionBar, on values/styles.xml:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- You can set the color of your status bar here, or with RN - see further on the answer -->
<item name="android:statusBarColor">#color/dark</item>
</style>
Don't forget to apply this theme to your MainApplication, in your AndroidManifest.xml:
<application
android:name=".MainApplication"
android:theme="#style/AppTheme"
...
To illustrate better, here's what it looks like:
With the NoActionBar (code above)
With parent="Theme.AppCompat.Light" and <item name="android:statusBarColor">#color/dark</item>
With parent="Theme.AppCompat", and an empty app name.
For the second part of your question, you can either change the color of your status bar here (see the docs for this), or within React Native.
go to
android/app/src/main/res/values/styles.xmlandroid/app/src/main/res/values/styles.xml
and add this code. it will remove
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:textColor">
#000000
</item>
</style>
</resources>
Issue
I'm attempting to change the background (colour/drawable) during the 'cold start' phase of my apps' launch.
I have a few test devices and I've created a simple custom theme which overrides the background attribute of the parent theme. When I launch my app, on my Android 10 device the background shows perfectly fine and full-screen (whether a colour or drawable).
On my Android 5.1 (Lollipop) device, I get no such luck and the background is just plain black.
Theme Code
This is how I've setup my theme in values/styles.xml...
<style name="MyTheme" parent =
"#android:style/Theme.DeviceDefault.Light.NoActionBar.Fullscreen">
<item name="android:background">#drawable/myDrawable</item>
</style>
Note: 'myDrawable' is defined (it's just a bitmap image). As mentioned, it doesn't apply on Android 5.1 during startup. Same if I just set a hex color value ('#ffffff' for example).
Am I misunderstanding something, or do I need to do something different for older devices?
You should use
<item name="android:windowBackground">#drawable/myDrawable</item>
I'm new to Android studio and I figured out how I can send my application to my phone. The problem is, In the preview, At the bottom, it has this auction bar (See photo) Is there a way to get rid of that? Because my phone (Samsung Galaxy S6 Edge) Does not have that, And it sits in the way if I want to place something at the very bottom. Because in android studio it may be at the very bottom, But on my phone, it isn't.
Also, Is there a way to make that top bar, That is now black, Sort of transparent? So it takes the colour of the background? You see it in a lot of apps. As I mentioned, I'm very new in android studio so sorry.
Thanks in advance
The control bar at the bottom is part of the emulator aka any phone without hard buttons. You can toggle to full screen and it will hide it for you.
For example code simply create new activity and select fullscreen activity. You will see that it manages it by touch of surface to reappear and timer to dissappear. Just remove that bloat and handle it yourself. Done !
As for the status bar at the top, it uses your activity default background. So if you want to change this go to your styles and add a background to your AppTheme and this will be the default background color of unspecified areas instead of black.
Example:
<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>
<item name="android:windowBackground">#color/blue</item>
<item name="android:actionMenuTextColor">#color/white</item>
</style>
The windowBackground color will drive the background color of unspecified areas unless you override the theme on any particular activity in the manifest. Goodluck.
I need to disable Activity transition animation for all the screens in my application. Previous solution worked fine for all Android version:
<style name="base_theme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowAnimationStyle">#null</item>
</style>
... but for Android 8 "Oreo" it cause black screen blinking for every transition (forward or back move). I.e. there is still no any animation, but very annoying blinking take place (90% chance, ~20-30 milliseconds, the whole screen).
According to my "research":
it does not depends on activity content and reproduced with empty activities
there is no any background work which could slow down the transition process
Intent.FLAG_ACTIVITY_NO_ANIMATION blinks as well
overridePendingTransition(0,0) doesn't work too
The only solution I could find:
Define an empty transition animation
<?xml version="1.0" encoding="utf-8"?>
<set />
and apply it to every activity in the application (onCreate & finish)
overridePendingTransition(R.anim.animation_activity_none, R.anim.animation_activity_none);
Question:
Is it some kind of new restrictions for Oreo (i.e. feature), or platform bug, or maybe the application issue?
Are there any other solutions?
[UPDATE]
One more finding. Make sure you call Activity finish() and overridePendingTransition() pair on the main thread! Otherwise thread race happens and overridePendingTransition not applied sometimes.
[UPDATE]
Google has confirmed it's a bug in Android 8.0, presumably fixed in 8.1.
So the "empty animation" fix is for years, until minSdkVersion == 27.
I had the same issue, and I managed to solve it, the idea is to play nothing, please see the xml below:
Values folder
<style name="yourTheme">
<item name="android:windowAnimationStyle">#style/ThemeApp.Animation.Activity.Replace</item>
<style name="ThemeApp.Animation.Activity.Replace">
<item name="android:activityOpenEnterAnimation">#anim/replace_anim</item>
<item name="android:activityOpenExitAnimation">#anim/replace_anim</item>
<item name="android:activityCloseEnterAnimation">#anim/replace_anim</item>
<item name="android:activityCloseExitAnimation">#anim/replace_anim</item>
<item name="android:taskOpenEnterAnimation">#anim/replace_anim</item>
<item name="android:taskOpenExitAnimation">#anim/replace_anim</item>
Anim folder: replace_anim.xml
<set/>
I have a ListView with some rows and a custom checkbox on the right hand side. On my OS 4.4 Nexus 4 it seems like a gentle gradient is being applied to the list row backgrounds, creating an ugly artifact on the checkboxes (they disappear half way down, and then invert for the bottom half). On other devices I don't see this problem, and I also don't see it in an OS 4.4.2 emulator.
I haven't been able to find any information online about this, so I'm not sure if it's specific to the device, or the exact OS flavor.
Is this something I can disable? If not, what advice should I give my asset designer?
Here's a screenshot:
The Holo.Light theme uses a subtle grey gradient background. It might only be more apparent on one of your devices due to the screen's contrast/brightness.
You can just set the background to solid white by using the android:windowBackground tag in your Activity's theme:
<style name="SolidWhiteTheme" parent="android:Theme.Holo.Light">
<item name="android:windowBackground">#android:color/white</item>
<item name="android:colorBackground">#android:color/white</item>
</style>
And then applying the theme to your activity in your AndroidManifest.xml like so:
<activity
android:theme="#style/SolidWhiteTheme"
...
>
...
</activity>
As Denley mentioned, the reason for this is the default background specified by the Holo.Light theme.
However, since this background is specifically affecting your ListView, I would suggest setting the background of your ListView in your xml file. Code below.
<ListView
android:background="#android:color/white">
Try specifying a background color for your activity (android:background). If the background is not explicitly set, the device may be using it's own device-specific default background, which is why the gradient is only shown on your Nexus 4 and not other devices.