How to set app launcher image from drawable folder? - android

Instead of using multiple images of multiple sizes in different folders like mdpi,ldpi,hdpi etc, can i put single image in drawable folder for app launcher icon so that i can reduce app size. What should i do for that.

Probably, try changing your manifest from the mipmap directory to the drawable one. If it doesn't work, I suggest just using a mipmap version with all the different sizes. If you think preparing the different icon sizes is difficult, it's not:
When you add the launcher icon, android studio will offer you to auto generated the various densities for you while you're in the image selection bit. So, you only have to add one image, incase you thought you had to resize them.

Its simple,generate icon of largest size ,which u think u may need anywhere ,and put that in your drawable folder. Android will automatically resize and use it according to requirement , This way you can effectively have just one image and let android handle sizing

Related

Android Studio 3.2 Add Image Of Custom Size (not icon)

When I right-click the Drawable folder and click New -> Image Asset, I'm presented with only four options: action and tab bar icons, launcher icons, launcher icons (legacy), and notification icons.
What if I want to add an image to just use in my app (not as a tiny icon)? Selecting any of the options above causes Android Studio to scale the image down to like 24x24dp when I want to display it at 100x100dp. So, when I display it, it looks really blurry. Why isn't there an option to add an image asset that's not tiny?
Limited modification is to comply with the material design specification. you could use vector asset if you want to get different size image.
and notice you should down image with SVG format, read the ref in here
another way is using thrid party plugins like Android Drawable Importer, which is flexiable and simpler.
Just copy the image to your drawable folder in the Android sidebar view. Make sure it goes into drawable and not one of the density-dependent folders, and you'll have an image with a custom size.
Be aware that images can't be too big in Android. It shouldn't be larger than 1600px in either dimension, otherwise you run the risk of a laggy interface or an OutOfMemory error.

android resizing images for all screens (ldpi,mdpi,hdpi,xhdpi) and put in folders

I am pretty new with android studio. I am wondering how you do all the converting thing ? You resize each image with gimp and creat all the folders. Or is there a program or function in android studio to do resizing for you ? And folders ?
Thank you for your help
You can use android-drawable-importer-intellij-plugin, I found it the best, all you have to do is import the image you want, and the plugin will create resized images for you.
Right click on your drawable folder
New > Image Asset for Launcher Icons, Action Bar and Tab Icons and Notification Icons
New > Vector Asset for Material icons, SVD's and PSD's
There is also a tool called Android Asset Studio which can do even more things for you
Use AndroidAssetStudio utility to do the same.
You organize your image/drawable resources in different folders within drawable folder, those are hdpi,xhdpi,ldpi folders. And have images resources in all these folders with respective resolutions with same name.
You could also user vector drawables that are resized according to screen size.
Go to this page to study this in detail

Shall I put 9-Patch Image in different drawable for different screen size or i can place it only one time in drawable for different screen size?

I have one 9 patch image but i don't know that where i have to put it. only one time in Drawable folder or i have make different folder ( like mdpi,hdpi etc) in drawable for supporting different screen resolution.can anybody suggest me.thanks
Nine Patch images are mainly used to reduce the number of images. So if you are using nine patch, there is no need to use it in different folder we can use it drawable folder alone. This will reduce the number of resources used in the project, which will obviously reduce the apk size too, etc...
Hope this is helpful :)
Both drawable/ and drawable-*dpi/ work.
But I put all drawable *.xml files in drawable/, and all png/webp/jpg files in drawable-*dpi/, which makes the folder cleaner.
As u may use different *.9.png for different screen resolution respectively, drawable-*dpi/ may be a better choice.
Hope it helps.

"Canvas: trying to draw too large bitmap" when Android N Display Size set larger than Small

I have a published app that is crashing at startup on Android N when the newly introduced Display size OS setting is set to too large a value.
When I look in logcat, I see the following message:
java.lang.RuntimeException: Canvas: trying to draw too large(106,975,232 bytes) bitmap.
I've traced the issue to an ImageView in my first Activity that shows a nice big background image. The image in question is 2048x1066 and is in my generic drawables directory, so no matter the density, this image will be used.
Everything works okay when the Display size setting is Small. But when I go up to Default, it stops working. If I then swap the image out with a smaller one, it works at Default, but if I go up to Large, it stops working again.
My guess is that adjusting Display size up causes your device to behave like a physically smaller device with a higher pixel density. But I don't understand what I'm supposed to do here. If I put in progressively smaller images for progressively higher resolutions, it won't look good on actually large displays. Or am I not understanding something?
Any pointers would be greatly appreciated.
I my case, moving the (hi-res) splash bitmap from drawable to drawable-xxhdpi was the solution.
I had the same problem. I didn't suspect my splash screen to be the problem, since it is displayed when the app is started, but it turned out the splash screen is the problem.
The splash screen in my case has xxhdpi resolution, and it was mistakenly placed in the drawable folder, instead of drawable-xxhdpi. This made Android assume the splash screen had mdpi resolution and scale the image to 3*3 times it's required size and trying to create a bitmap.
I solved the problem after adding the below code into the Manifest file's application tag in between android: lines.
android:hardwareAccelerated="false"
I don't know would it help some one, but I'll just leave it here.
In my case - problem was only on Sumsung devices with Android 7, and problem was in splash screen proportions. after changing height to 1024 px - everything works fine
Move your image in the drawable to mipmap-xxhdpi.Your image is in bitmap format so you should put your image in mipmap folder,then it will work
There are some scenarios where Original Bitmap needs be Drawn into ImageViews, Photo Editing apps etc...,
as bay mentioned above setting
android:hardwareAccelerated="false"
will Cause bad UI experince, You can set hardwareAccelerated Only one selected Activity where high res image to be drawn
<application android:hardwareAccelerated="true">
<activity ... />
<activity android:hardwareAccelerated="false" />
</application>
Try to use Bitmap.Factory class, this link will help you
Loading Large Bitmaps Efficiently
if you use Picasso change to Glide like this.
Remove picasso
Picasso.get().load(Uri.parse("url")).into(imageView)
Change Glide
Glide.with(context).load("url").into(imageView)
More efficient
The icon files are too large for Android to efficiently and smoothly load. Android recognizes this with its smart algorithms.
You can resize the icon files using Final Android Resizer by asystat. Resize them to "xhdpi" or lower.
Place the resized photos in drawable or overwrite over the existing large icon files.
Then, you're done.
if you are using glide and you are loading 1k of images at a time or some images then it is issue of glide or whatever you are doing to use to set the image view. you can resolve it just by applying scale type in glide.
In my case, I just changed the canvas of image which is used in the background using Paint3d(or you can use any other). Here I am sharing a screenshot just go through it.
it is solved by resizing the images to a lower size.
Need to add Manifest file's application tag in between android: add below lines.
android:hardwareAccelerated="false"
Just an addition to the Johan Franzén's answer, maybe it's a good idea to not only add drawable-xxhdpi density folder, but also add another density folder.
So whatever the android version and size, your app can prepare the image source with the right size :
Change your folder view on the top left from Android to Project
Go to YourProjectFolder folder > app > src > main > res
Prepare the original image with your best resolution, and split it into each folder size automatically. You can do it in Baker
Then create a folder with another density, namely:
drawable-hdpi, drawable-ldpi, drawable-mdpi, drawable-xhdpi, drawable-xxhdpi, drawable-xxxhdpi
Put each image into the appropriate folder
i solved the problem by simply changing the image extension to .png extension, and it worked just fine with me.

How to prevent a drawable from becoming blurry?

When i copy-paste an image to the drawable file, i get one image with the original resolution. When i use the New--ImageAset way i get a lot of images for different screen densities but they are all blurry, even xxhdpi! How can i have the different densities inages without this problem?
Im surprise i didnt noticed it before!
I read this but it hasnt helped me
Android ImageView blurry?
http://developer.android.com/guide/practices/screens_support.html
Any advice am i doing it wrong?
EDIT
I tried the AndroidAssetStudio but it still happens
Before
After (xxhdpi)
Cant i get it to be the ldpi and then make it scale up from it or something?
You can create your image in different resolutions using Android Assets Studio. Then, copy paste the image to the respective folder. This will give you a proper image, without blur.
There is a plugin exactly made for the same purpose. You can use that plugin to make different sizes of the same image. You have to copy/paste a single image in drawable folder. Then right click drawable folder and select
NEW>Batch_Drawable_Import. Select the size for your image and it will itself make the other sized images for you.

Categories

Resources