Android Image Asset is not drawn - android

I am trying to implement a splash screen for my application, following the usual method; defining a new theme inside the styles XML file that places a drawable as windowBackground and reverting to the main theme in the Activity's onCreate().
However, I am having problems when showing the logo I developed in Photoshop: I exported it as a 144x144 PNG file, created an Image Asset with it (replacing the standard ic_launcher drawable) but when I try to visualize it inside an XML file, this image is displayed instead
Screenshot
Any ideas? I've also tried to create a vector asset from the .psd but nothing is shown either...

https://romannurik.github.io/AndroidAssetStudio/
use this link to generate your icon. It will work.

Change the code and so on
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#color/your_background"/>
<item android:drawable="#drawable/your_image">
</item>
</layer-list>

Related

Unable to change the default white splash screen in flutter

Here's the code in launch_background.xml
<?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/black" />
<!-- You can insert your own image assets here -->
<item>
<bitmap
android:gravity="center"
android:src="#drawable/applogo" />
</item>
</layer-list>
I have changed the color to 'black'- yet I get a white splash screen, neither do the logo shows up.
I have placed the logo (png) in the drawable folder. Can anyone help me with this?
first, you need 2 files to make this work, first are the files in the drawable and drawable-v21 folders they should have
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#color/background_color" />
<item>
<bitmap android:gravity="center" android:src="#mipmap/launch_icon" />
</item>
</layer-list>
#color/background_color
is a custom color style for android which you would have to create it next
#mipmap/launch_icon
is a custom icon image you have in your mipmap folders you can create the sizes by using https://appicon.co
and the second file will create as a colors.xml in the values and values-night folder this file will carry the color you want to use
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="background_color">#000000</color>
</resources>
I think you want to remove the white screen at app boot time. Check This library, you can use color or logo image anything else instead of the white screen.
Click this Link
Here is the Preview
for android
open launch_background.xml file inside the Res folder and add one new splash screen image in the drawable folder. Now change code in two places. See tutorial example here
Edit this launch_background.xml by adding a new item and set the splash screen image as an item value.
For iOS app
Open flutter project on Xcode for Adding splash screen to flutter ios app. To open the iOS module on Xcode, open android studio and on the top menu select tools. Go to flutter –> open ios module on Xcode.
On Xcode window, Click on Runner-> Runner -> Assets.xcassets folder. Here you can see LaunchImage paste your splash screen image with all three different dimensions in this folder.
Open LaunchScreen.storyboard
Again on the left side menu just below the Assets.xcassets folder, you will see LaunchScreen.Storyboard. Click on view controller scene -> view controller -> view. Note: – select (click on ) view only don’t click on LaunchImage. You already paste the new splash screen in the LaunchImage folder in the previous step. So you will see the same new image here in this window. When you select (click on ) view then on the right side window you can see options to change view settings like content mode, background, alpha etc. change the background colour as you want and set content mode to scale to fill.
Adjust Splash Screen
You can adjust the splash screen position, size & background colour on the same window. Just click on launchImage OR select the image on the preview window. You can resize the image and can adjust the image position. On the Right side window, you can make another set as well.
iOS App Splash Screen is Ready.
Now flutter white splash screen problem has been resolved successfully for both android and iOS. You can change the flutter splash screen background color as per your requirements.

How to create a gradient color background for splash screen in Flutter?

I'm working on the splash screen for my Flutter app, and in drawable folder I have to create a file called colors.xml in order to change background color for my splash screen. I'm finding it hard to make it a gradient color. My intention is to create a gradient background color that would start at the top left and end at bottom right, using two different colors. Does anyone have an example of how to do that in Flutter? Thanks!
P.S. An is there a difference in the process for android and ios?
1 In \android\app\src\main\res\drawable\launch_background.xml
change this :
<item android:drawable="#android:color/white" />
to :
<item android:drawable="#drawable/gradient_background" />
2 Create this file \android\app\src\main\res\values\colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="gradientstart">#3587d0</color>
<color name="gradientend">#36f1d3</color>
</resources>
3 Finally, create this file \android\app\src\main\res\drawable\gradient_background.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#color/gradientstart"
android:endColor="#color/gradientend"
android:angle="90"/>
</shape>
For Android first define two color in your colors.xml:
<color name="gradientstart">#888888</color>
<color name="gradientend">#111111</color>
then in \android\app\src\main\res\drawable\launch_background.xml just replace this:
<item android:drawable="#color/background" />
to this:
<gradient android:startColor="#color/gradientstart" android:endColor="#color/gradientend" android:angle="315"/>
and for ios according to this question
If your gradient is a simple vertical or horizontal gradient, and
you’re really concerned about asset size, you can define a very narrow
image and then add an image view with “scale to fill” content mode.
But these images are so small anyway, the amount of space saved will
be negligible, so I’m not sure it’s worth worrying about.
I found use of flutter_native_splash much more easy and direct. Here's a link on the steps to creating one. First design your desired gradient as an image and instead of adding color, add a background_image on the pubspec.yaml file.
Something like:
flutter_native_splash:
image: ""
background_image: "assets/my_splash_background.png"

Create Launcher icon using Image Asset without background color or xml in Android Studio 3.0.1

You might be thinking this question is a duplicate of this one. But since then, Android Studio has been updated and the solution given there is not working anymore.
Why are we forced to have a background when creating an Image Asset? What's the reason behind this? How we are supposed to change the launcher_icon without having any background? I don't see any option to disable the background in Image Asset.
Alternatively, I use an empty background but this doesn't work in Full Bleed Layers:
<?xml version="1.0" encoding="utf-8"?>
<vector
android:height="108dp"
android:width="108dp"
android:viewportHeight="108"
android:viewportWidth="108"
xmlns:android="http://schemas.android.com/apk/res/android">
</vector>
Or, just remove the background, but this will add a white background in your launcher_icon:
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Remove the background here and leave the foreground -->
<foreground android:drawable="#drawable/ic_launcher_foreground"/>
</adaptive-icon>
Or, change icon type into Legacy Only and set shape to none:
Still, there's a white background in the launcher icon when installed.
So how can I get a transparent background or none for that matter, for my Launcher icon using Image Asset?
It is not a problem of the icon you created with Android Studio, but it's a problem related to your specific device you're testing the application on.
In fact, in the Image Asset if you specify the Shape to None, you get a trasparent background.
To address your problem, please try to use a different Home theme, like the Nova Launcher; you can change the home theme in Settings - Home.

How to set View to ActionBar icon? not by drawable

I'm trying to use CircleImageView as ActionBar icon (like chatting activity in WhatsApp). I've tried this approach:
CircleImageView actionBarIcon_Profile = new CircleImageView(this);
actionBarIcon_Profile.setImageDrawable(getResources().getDrawable(R.drawable.my_picture));
actionBarIcon_Profile.setLayoutParams(new LayoutParams(48, 48));
actionBarIcon_Profile.setId(R.id.actionBarIcon_Profile);
getActionBar().setIcon(R.id.actionBarIcon_Profile);
ids.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item type="id" name="actionBarIcon_Profile"/>
</resources>
It seems like ActionBar setIcon() only accepts drawables as input. I could have setup a circular shape xml and put it in my drawable folder, but even that I have to change the background of that xml file to fit my need. Any suggestions?
link - http://javatechig.com/android/actionbar-with-custom-view-example-in-android
see if this link helps you

Easy way to change ProgressBar standard color scheme in Mono for Android?

I am looking for a way to change the tint and background colors of a standard android ProgressBar in Xamarin Studio. Found some tips for how this is done in java like this:
myprogress.setBackgroundDrawable(c.getResources().getDrawable(R.drawable.progress));
But I couldn't figure out how to use this in Xamarin. I have also seen the pretty large xml files, making gradient backgrounds. But shouldn't there be an easy way to just change the colors without any gradient?
you should probably go with this.
in res/values add new style by adding
<style name="Theme.MyAppTheme.Process" parent="android:Theme.Light">
<item name ="android:background">#2D2D2D</item>
<item name ="background">#2D2D2D</item>
</style>
Now use this style in your ProgressBar.
myprogress.setProgressStyle(R.style.Process);
you can change color code in backgroud of style..
To convert the Java to C#, it would look like this:
myprogress.SetBackgroundDrawable(Resources.GetDrawable(Resource.Drawable.progress));
All you need to do is put the drawable (png, xml, etc) you want to use as the background in your Resources/drawable folder. If you just want a gradient you should use xml instead of a bitmap. Create a new xml file in your Resources/drawable folder, here is an example of a blue gradient:
<?xml version="1.0" encoding="UTF-8" ?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#065b92"
android:endColor="#1183ce"
android:type="linear"
/>
</shape>

Categories

Resources