First of all ... I apologize for my English.
I am trying to add a background to the notification panel, the issue is that I have already achieved it by modifying the file qs_background_primary.xml located in SystemUI/res/drawable
This is the code I am using:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:drawable="#android:color/black"/> <!-- the image is very small, so add a black background -->
<item>
<bitmap android:scaleType="fitXY" android:src="#drawable/background_bg" android:gravity="center|bottom|clip_vertical" xmlns:android="http://schemas.android.com/apk/res/android" />
</item>
</layer-list>
Once the background with image and compilation is ready, one problem bothers me and it is that when I slide the navigation bar the image looks horribly, as if the size started from 0 to its original size once it was completely slid.
This is what the size looks like:
This is what the full size looks like:
Related
I am having an issue with viewing my splashscreen as per the design.It shows an incomplete vertical view but a complete horizontal view.
Here is the splashscreen design:
Here is what I get as display when added to my project:
I am using two images as bitmap and combining them.
Below is my splashscreen.xml file:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<bitmap
android:gravity="fill_horizontal|fill_vertical"
android:src="#drawable/ic_splash_screen_bg_xx"/>
</item>
</layer-list>
I tried setting android:gravity value in my splashscreen.xml to:
android:gravity="fill_horizontal|fill_vertical" yet I still get same incomplete vertical display
You can use SplashScreenAPI introduce in android 12.
I want to make the splash screen background transparent so that it shows only an icon on the screen when the app starts.
What I have done so far in launch_background.xml for Android:
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#android:color/transparent" />
<item>
<bitmap
android:src="#drawable/index"
android:gravity="center"
/>
</item>
</layer-list>
But what I got was a black background like:
The Image
What I want, something like this:
The image
How to approach this problem properly? Thank you!
BTW: What about IOS?
I downloaded a transparent image, and used it as my background image under flutter_native_splash in flutter. It worked perfectly.
flutter_native_splash:
background_image: "lib/assets/transpbackground.png"
image: lib/assets/translogo.png
android_gravity: center
fullscreen: true
ios_content_mode: center
..android: true
..ios: true
I am trying to create a splash screen using this tutorial by using an additional theme.
This is my launcher theme in styles.xml:
<style name="AppTheme.Launcher" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<item name="android:windowBackground">#drawable/ic_launch_screen</item>
<item name="colorPrimaryDark">#color/color_white</item>
</style>
This is the ic_launch_screen.xml file:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#color/color_white" />
<item>
<bitmap android:src="#drawable/ic_splash_screen" />
</item>
</layer-list>
The ic_splash_screen file is already a 9-patch file looking like this:
In the 9-patch preview in Android Studio it shows that, if stretched, the logos will not be resized and look perfectly aligned.
Yet, when I use it in this combination, the splash screen looks stretched on my Huawei and Samsung but not on the pixel 2 emulator:
Huawei Mate 10 Pro & Samsung Galaxy s9+ (they are stretched the same way):
On the emulator it looks perfect like this:
The problem is not because of the system navigation. It still looks stretched on the Huawei when I use three key navigation like in the emulator.
I have already tried playing around in the ic_launch_screen.xml by using <nine-patch> elements or the gravity:center attribute but it looks even more messed up then.
I'm not sure why 9 patch isn't scaling but I can propose an workaround. You could create 2 drawables, First one with text pass13 and other one with logo. Now you can create the folowing layer-list:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#color/color_white" />
<item>
<bitmap
android:gravity="center"
android:src="#drawable/drawable1" />
</item>
<item>
<bitmap
android:gravity="center|bottom"
android:src="#drawable/drawable2" />
</item>
</layer-list>
Now it should scale well.
Based on this tutorial and this answer, which also references this other tutorial, using a theme's android:windowBackground along with a <layer-list/> appears to be the most approved method of creating an Android Splash Screen
Using this technique centering a logo on screen is easy; however, I want to position graphics along the top or bottom of the screen. I've run into problems because, as seen in the screenshot below, the windowBackground appears to be drawn behind both the Status Bar at the top of the screen and the Navigation Bar at the bottom thus making the graphics appear cut-off
Question: Is it possible to instruct the windowBackground to position itself below the Status Bar and above the Navigation Bar? If not, using the windowBackground Splash Screen technique is it possible to create a splash screen that isn't covered by the Status Bar or Navigation Bar?
To reproduce the problem, create a new Android Studio project which will get you the ic_launcher drawable and follow one of the tutorials linked above but use the following layer-list drawable
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:opacity="opaque">
<item android:drawable="#000000"/>
<item>
<bitmap
android:gravity="left|top"
android:src="#drawable/ic_launcher"/>
</item>
<item>
<bitmap
android:gravity="center"
android:src="#drawable/ic_launcher"/>
</item>
<item>
<bitmap
android:gravity="bottom"
android:src="#drawable/ic_launcher"/>
</item>
</layer-list>
You may set windowDrawsSystemBarBackgrounds to false in your theme for lollipop and higher versions.
Example:
res/values-v21/styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme.Splash">
<item name="android:windowBackground">#drawable/splash</item>
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
</style>
</resources>
I have a problem while trying to implement a layer-list xml file in which I just want to be a gray background with an image in the middle. The problem is that I want to fix the center image to 200dp (width and height). How can it be achieved? I have found that the only way is to use the paddings, but this does not allow me to fix the image to 200dp, independently of the screen... Is it possible to achieve?
Thank you,
The code:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="#color/gray_dark"/>
<item>
<bitmap
android:gravity="center"
android:src="#drawable/ic_launcher_rounded"/>
</item>
</layer-list>
Note:
The purpose is to use it as a theme's background in order to simulate a splash-screen (If done as an activity layout takes more time and does not look like a real splash-screen)
This is an old question, but maybe someone will find this answer useful.
To specify bitmap size, you can use this xml.
<?xml version="1.0" encoding="UTF-8" ?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
android:drawable="#color/gray_dark"/>
</item>
<item
android:height="500px"
android:width="500px"
android:gravity="center">
<bitmap
android:src="#drawable/ic_launcher_rounded"/>
android:gravity="fill"/>
</item>
</layer-list>