New Splash screen is shown cut in a cyrcle shape - android

I'm trying to replace my old activity based splash screen in my Android app with the new Splashscreens API
So i've created a svg of my app logo, create the theme, and set in my MainActivity the installSplashScreen but the logo in the Splashscreen looks like this when app is launched:
How could i fix that issue?
Here is what i've done style.xml:
<style name="Theme.App.Starting" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">#color/colorAccent</item>
<item name="windowSplashScreenAnimatedIcon">#drawable/ic_visual_vector</item>
<item name="postSplashScreenTheme">#style/AppTheme</item>
</style>
Manifest:
<activity
android:name=".MainActivity"
android:theme="#style/Theme.App.Starting"
android:screenOrientation="portrait"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
MainActivity:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SplashScreen.installSplashScreen(this);
setContentView(R.layout.activity_main);
...

What you can do is to wrap your icon in an inset drawable so that it is drawn inside the circle.
For example, create a drawable/splash_inset.xml resource:
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="#drawable/ic_visual_vector"
android:insetLeft="72dp"
android:insetRight="72dp"
android:insetTop="72dp"
android:insetBottom="72dp"/>
The actual inset values depend on your image and its aspect ratio, using 72dp here on all edges as an example.
Then apply this drawable as your windowSplashScreenAnimatedIcon.

In Android 12, if your icon is bigger than the required size, it'll be cut off.
App icon without an icon background: This should be 288×288 dp, and fit within a circle of 192 dp in diameter.
For example, if the full size of an image is 300×300 dp, the icon needs to fit within a circle with a diameter of 200 dp. Everything outside the circle will be invisible (masked).
More info: https://developer.android.com/guide/topics/ui/splash-screen#elements

My answer could be late but I had same issue. I only added android:gravity="center" to my drawable/splash_logo.xml file and using the splash_logo.xml in styles.xml file.
<layer-list>
<item android:gravity="center"
android:src="#drawable/splash_logo_icon" />

This happens when I run my app on an emulator 30s but when I run it on a physical device it show well. Looking at your code and comment above, is it really required you implement the image from the styles/Res ?... I recommend you create the imageView in your splash_screen.xml

Related

Flutter splash screen not working with launch_background.xml

I can't seem to show my own splash screen, every time I launch the app the default, blank splash screen is shown even though I've set up everything in launch_background.xml and the other files in res. I've also set up all the relevant icons in drawable and mipmap.
launch_background.xml:
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<color android:color="#color/splash" />
</item>
<!-- You can insert your own image assets here -->
<item>
<bitmap
android:gravity="center"
android:src="#drawable/splash_icon" />
</item>
</layer-list>
styles.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
<style name="LaunchTheme" parent="#android:style/Theme.Light.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<item name="android:windowBackground">#drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="#android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
colors.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#191919</color>
<color name="splash">#191919</color>
</resources>
<activity> tag in AndroidManifest.xml:
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/LaunchTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
The splash screen should show an image and a different background color but instead it just shows the default blank white screen. I'm not using a custom splash screen for this. I just want at least the colors to change but even that is not working.
Also make the changes in drawable-v21/launch_background.xml. This will be used for Android API Level 21 or higher.
Pub.dev has a package that will create the native splash screens for you: flutter_native_splash

Can I set the colour of the Launcher Icon?

I am writing a very simple app as a starter and using a material design icon as the launcher icon. Is there a way I can set the colour of just the launcher icon like I can the size and shape?
Here is my code from AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="#drawable/gasstation"
android:label="#string/app_name"
android:iconTint="#color/sysGreen"
android:roundIcon="#drawable/gasstation"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
The statement android:iconTint seems to be OK in that Android Studio has not flagged it as an error but it has no effect. The launcher icon is still the grey colour of the downloaded image resource.
Is this possible? Any help greatly appreciated.
If you retrieve the icon from a drawable, basically a small image you have in your resources, you cannot change the color.
What you can instead do is to use the tool Image Asset Studio, here is the link
As explained
In the Project window, select the Android view. Right-click the res
folder and select New > Image Asset.
then follow the guide..
Anyway from API version 21, you can tint drawables,
as explained in this post
Well ... I finally did it as follows.
right click on res>new image asset>clip art>pick the icon
you can set the foreground colour manually in the Configure Image Asset screen

How to show an ImageView in a style?

Before, when my app first started up, there was a white screen. So I created a style with a black background in styles.xml and referenced it in my manifest:
<activity
android:name=".InitialScreen"
android:theme="#style/Theme.Transparent"
android:label="#string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
styles.xml:
<style name="Theme.Transparent" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:background">#000</item>
</style>
The black screen shows successfully, How can I show an ImageView in this style?
In your mipmap/drawables folder of your project add an image of your choice. Inside your style remove the background and add a windowBackground... inside reference your drawable or mipmap that you have added.
E.G:
I want my background to be a certain image, it's name will be background.png. I will go to the directory of my project and add this image to the drawables or mipmaps folder, depending on which you're using. In your style have this:
android:windowBackground="#drawable/background"
Or #mipmap/background depending on which you are using.
Why I have used windowBackground and not background
I have just recently done the same thing and realized that I had made a mistake when using background instead of windowBackground because if you have a layout/view which has no background specified it will use the same background. This will cause the background to repeat.
Hope I helped,
-Daniel

Android splash screen is shrunk

I have trouble with android splash screen.
I made splashscreen like these
/platform/android/res/drawable-hdpi/background.9.png
/platform/android/res/drawable-mdpi/background.9.png
/platform/android/res/drawable-xhdpi/background.9.png
/platform/android/res/drawable-xxhpi/background.9.png
/platform/android/res/drawable-xxxhdpi/background.9.png
These are made by ticon automatically.
and have confirmed these looks OK(correct background.9 below).
However, when I open appication (on Nexus7 2013),splashscreen looks much smaller.
I mean background.9.png are centered and there are white blank around image.
correct background.9
shown splashscreen
How can I adjust it to the screen???
To adjust it to the screen, you just have to resize it accordingly and then create a drawable file like this for each screen size (this exemple will display a gradient background with an image in the center)
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#2b3143"
android:centerColor="#37465e"
android:endColor="#55647c"
android:angle="135"/>
</shape>
</item>
<item>
<bitmap
android:gravity="center"
android:src="#drawable/myCuteLogo"/>
</item>
You then create a style and set the property android:windowBackground with the drawable you created:
<style name="SplashScreenStyle" parent="myAppTheme">
<item name="android:windowBackground">#drawable/splash_screen</item>
</style>
Then create a SplashActivity that will display the Splash screen:
public class SplashScreen extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent(this, Activity_a_Main.class);
startActivity(intent);
finish();
}}
Lastly in your manifest set the SplashActivity as the Lancher activity and set its theme to the style you created:
<activity android:name=".Activities.SplashScreen"
android:theme="#style/SplashScreenStyle">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I hope this helps you
NOTE: If you set the style you created as the whole application's theme, it will show your drawable in weird places, like in the background of a soft keyboard

no orientation notification when translucent set

Using phones that have android 2.1 & 2.2 installed, using the simplest case of a hello world app and add android:theme="#android:style/Theme.Translucent" to the activity in the android manifest to have the app be transparent, the app sticks as portrait only and won't rotate to landscape when the phone is rotated.
Take the line out and the app rotates ok. This is verified by adding the override of onConfigurationChanged and putting a breakpoint in that routine. Brk hits when translucent isn't applied, doesn't when you add translucency.
However, using a samsung galaxy tab using andr 2.2, rotation works ok even with translucent applied. Anyone have any ideas on this?
I had a same problem. Just add android:screenOrientation="sensor" in the manifest file after you specify theme:
<activity
android:name=".SplashActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.Translucent.NoTitleBar"
android:screenOrientation="sensor">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
So far I tested it on android 2.2 and 4.1 - works as expected.
I have a same problem... but in my case I used Translucent because I solve redrawn warning (this warning appear when set color on android:background)
I solved the warning creating a Theme with parent Theme.Lignt and rewrite two attributes
Something like this
<style name="MyTheme" parent="android:Theme.Light">
<item name="android:windowBackground">#color/my_background</item>
<item name="android:colorBackground">#color/my_background</item>
</style>
If you need use Translucent in ApiDemos has a sample when an activity have a translucent theme and orientation service works well

Categories

Resources