I generated 9patch images from Simple 9 patch generator available free on the internet for the splash screen. When I write android:background="#drawable/splash.9", it doesn't recognize the image.
Plus , when I select Android from the drop down menu on left top side , I don't see the images I put in different drawable folders.
No need to add the .9 suffix. It's just there to tell the build environment that this is a 9patch. Link to documentation.
android:background="#drawable/splash"
should be enough
Related
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.
See the image:
Why does my icon look different to the other icons on the screen? In Android Studio, I set trim to zero and yet it still shows up like this on my phone. I have Nova Launcher installed which makes all my apps have rounded icons, but look at the Google Maps, and Instagram, how do I get my icon to fill the circle?
WONDERING WHY IT DOES THIS REQUIRES VERY SIMPLE EXPLANATION:
in new boiler plate code that comes on android studio project generation it makes some extra files in the mip map ! as for the big api based phones have a nature to put a round bracket icon behind every launcher icon of the apps! So All you need to do is very simple if you want to override that! follow the image based foot steps shown below
HERE IS HOW YOU CAN ADD A CUSTOM ICON WITHOUT ANY ROUND whit icon behind it!
STEP ONE! .
go on your any res folder drawable or mipmap and right click and reach to the option shown in the image:
STEP TWO! .
After clicking on your image asset it will ask to make icons for both old and new phones! but we don't have to select that! ok? see the image for it!
STEP THREE! .
CLICK THE ICON TYPE SPINNER(DROP DOWN) and select mipmap legacy only like shown here
STEP FOUR! .
CUSTOMISE YOUR PICTURE LIKE shown here! by back ground etc how ever you like!
STEP FIVE! .
You will see images being saved only in mipmap folder not in the ic_launcher round folder
STEP SIX! .
You can see the image you created as icon in ic_launcher folder
but
STEP SEVEN! .
THERE IS a GOTCHA STILL SOME IC_LAUNCHER BUILTIN TEMPLATE PROVIDED files are there you have to delete that folder as shown
:It will cause the alert that how we are supposed not to do that but its ok! just follow the step 8 and you will have the icon of your choice no matter what phone you are testing your app on!
STEP EIGHT! .
GO TO YOUR MANIFEST FILE AND DELETE THE HIGHLIGHTED line and you are all set! ^_^
With the release of Android Oreo the launcher icons changed a lot.
But with Image Asset Studio (integrated in Android Studio) we can easily generate everything we need (26+ and 25- APIs). Here is explained how these new adaptive icons work.
In this article you can read everything you need to know step by step, but in summary: you need two icons (square and rounded) for 25- APIs, and two layers (background and icon image) for 26+ APIs. Android Studio will generate everything you need if you can provide those elements.
I'm trying to import a PNG image asset to my project. But the image is losing details. It's just retaining the outer background. The image is transformed to a solid asset:
As you can see, the source asset has a white-tick in the center. But, after importing, it just remains as a solid circle with no ticks. Any solutions?
UPDATE: Tried Android asset studio, but with the same result. What am I missing?:
Thanks to Shafayat Mamun, a workaround is figured out. Here's what I did:
Go to Android Asset Studio
Select Generic Icons (it didn't work for any other option)
Upload the image, pick your color and drag down the color scale to 0% using the scale.
Download the zip and extract to the main folder of the project.
PS: This, though helped me solve my query, but the question remains intact. Why is android studio not capturing the image details while importing? Same is the case while I select Action bar and tab icons in the Android Asset Studio.
do you really need to convert it in the action bar and tab icon generator? i recommend using the simple nine-patch generator here if you want a 9patch image. or the launcher icon generator and set the shape to none and change the image's name after downloading. if you use the launcher icon generator, just modify the shape. if you use the nine-patch generator, you can click trim and click edge transparency if you want to remove the spaces beside the image.
I had the same problem and the Android Asset Studio workaround was a great help. However I discovered another work around. In Android Studio when you create an image asset, instead of selecting Action Bar and Tab icons, I chose Launcher Icons from the drop down. Then the images displayed for me. I had to search for their name and they do not get stored in the drawable folder they end up in the mipmap folder.
So the steps are:
For Android Studio:
Right click on res, new Image Asset
On Asset type choose Launcher Icons
Choose the image path
Give your image a name in Resource name
Next->Finish
The image will be saved in the /res/mipmap folder
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.
I have an interesting issue, and I dont know how to handle it.
So, until now everything was fine, I was able to build my project. I just replaced an image with it`s 9patch version in three different sizes(mdpi, hdpi, xhdpi).
tw.setBackgroundResource(R.drawable.tag_rotate)
This is the line, where the building failing. It`s interesing, because the studio is able to show me the image on the left, and it is NOT marked as red. But the build is failing with the following message:
Error:(196, 52) error: cannot find symbol variable tag_rotate
UPDATE:
if I remove the image from the code, and replace with a normal image, it works ! Im using the default 9patcher provided by SDK
What kind of nine-patch generator do you use?
I recomend you to use this generator.
I tried to use standart android 9patch generator, which delivered with android SDK, and I had the problems with it.
Check if there is a line on your imports that says import android.R;.
If there is,Delete the import and it should be fine.
The Draw 9-patch tool is a WYSIWYG editor that allows you to create bitmap images that automatically resize to accommodate the contents of the view and the size of the screen. Selected parts of the image are scaled horizontally or vertically based indicators drawn within the image.
http://developer.android.com/tools/help/draw9patch.html
Nine-patch generator
https://android-ui-utils.googlecode.com/hg-history/9472134d092f3375aa9cf767d6a4b2eca561c0ba/asset-studio/dist/nine-patches.html
If you are make online generator tools then Don't use the any special character for image name
The 9 patch tool in android studio is automatically generating bad patches.
You need to repatch till the red bad patches go away and the error should be fixed. To see bad patches just select the Show bad patches checkbox.