How to place 9patch generated images in Android Studio? - android

I used the freely available Simple 9patch generator available online, to generate a logo for my app's splash screen.
But how do I place it in Android Studio drawable folder?
Do I have to make separate drawable folders like ldpi, hdpi etc?
I tried that but when I try to set the image on a layout, it gives me an error saying
Cannot resolve symbol #drawable/something

You need to make sure, you have place the images in the correct folder. Here's an example,
Original post: Add 9-patch image to Android Studio

Get rid of the .9 in #drawable/splash.9. It is just #drawable/splash. .9.png is the file extension, and file extensions are not used in references to resources.

Related

Android Studio: Is is possible to set default drawable folder?

I am having a rather annoying scenario where I work with a lot of drawable shapes, many of which are slightly changed variants of others. The annoying thing is, when I paste the drawable, it automatically defaults to a random resource folder. See bellow photo. I want it to go directly to the standard drawable folder, not some other density drawable folders without having to manually change the folder every single time.
Is this even possible?
You can change the View from Android to Project if you are copying & pasting multiple images in a row. You can simply paste it to the drawable folder.

how do you use svg in drawable folder?

i am creating a bottom navigation bar for a android app following this guide
however, when using svg in android:icon and building it, it shows a error
Error: The file name must end with .xml or .png
i found out that i needed to move the svg to the assets folder. but if i move it, i can't use the svg... any help is much appreciated, thank you
The answer above gives a link to convert pictures from SVG to XML, but this tool is not for free(only for one SVG file)
So why not to use ANDROID build-in tool?
The best way is to go to res-> drawable-> Vector Asset -> Local file (SVG, PSD) ->select your SVG file from the place you save it.
and you are done :)
Android uses vector drawables which are xml files rather than SVG's.
You will have to convert the SVG to a vector drawable. Many ways of doing it but a handy web tool is available here.
It won't do complex SVG's but copes with the majority.

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

adding images to drawable folder - showing blank image

while adding images to drawable folder using image asset i come accross this
How to solve this issue?
there is not any problem its the new window to add image asset android studio designed.
choose the image for asset type and give the path. then the android studio will generate different size of your image asset in different mipmap folders.
its a lot easier than before. if you dont want to use mipmap folders just copy and paste your file into youre desired folder in android studio manually.

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