Android Studio Adding image asset not working - android

I'm trying to add an image in Android studio by right clicking on the drawable folder->new->Image Asset, I add an Action Bar and Tab Bar icon with a custom image and I click finish and it looks like its doing something but nothing appears in the drawable folder. I'm also unable to reference the new image name in any xml. What's funny is if I go to re-add this image, it says the image already exists and it will be overwritten. Am I doing something wrong?

I create a new project with Android Studio and generate image asset in the new project. It begins to work. I don't know what's wrong with the previous project. Hope it also helps for you.

As #Varun said, Before click on Finish, check save path by click on "Next" button.

TLTR: fix any other icon type you touched before.
In my case it was because of wrong path to foreground image path (the source image was deleted):
So even after changing the icon type the error does not disappear (buttons are disabled):
So fix other icon types.

In Background Layer set Asset Type to "Color"

Related

I paste image inside the drawable folder in android studio 4.1 , it shows red lines (error line) in image name

This is my project folder, when i adding first image then it not show any error but after adding the 2nd and 3rd image it show the red lines.
I don't know where i do mistake, if anyone knows then please help me.
In Android Studio, click on View > Tool Windows > Resource Manager in the menus or click on the Resource Manager tab to the left of the Project window.
Click the + below Resource Manager, and select Import Drawables. This opens a file browser.
Make sure the name of the image you are trying to add does not resemble some keyword. I was trying to add an image in drawable with name "try". When i made it "tried" error went away. So, name your image != any keyword.
FOR YOUR CASE IN PARTICULAR:
Try invalidating cache and restarting it. Moreover, also check if the problem persists only with these two images or others too.
Names should be in lowercase.
Therefore never use names with uppercase letters in it
try removing numerals and keep a meaningful name. Also ensure that the names are in lower case
drawable folder is wrong place for png files.
In drawable are stored xml files
All png files should be stored in mipmap folders
If you want have only one png for all resolutions, store it in mipmap-anydpi
I found the problem.
Add the same image to the default drawable folder. Android Studio automatically doesn't add it to the default drawable folder.
It usually happen because of the name assigned to image file. try to put the name of file in snake_case.[error][solution]
solutionC.pngerror

The android studio changes the background of button

I have a problem with my Floating Action Button. I want to get the same "plus" button as in google design, however, when I import the "add_white" icon from material design studio and put it into project, it is redefined to have black background which completely distorts the effect.
I show on the attached picture how the problem looks like - the image in all possible dimensions is correctly inserted in the folder, however, the android studio reads it differently.
Thank you in advance,
Grzegorz
How to fix it/ or just get the proper "cross/plus" sign to the button?
I'd recommend you to download the icon in svg format from https://design.google.com/icons/#ic_add, you can add it to Android Studio by doing a right-click on the project and selecting Vector assets, you'll be able to remove your 5 ic_apps_white_48 pngs and use the one imported.

My laucher icon is glitching, its cut into half

as title says, my ic_launcher cut into half, here is the pic
this is the original:
how did this happen, is there any suggestion?
Try using a png file.
or simple right click on your project, select new and then choose Image Asset. Now you will have plenty of options.
It should work
I suggest you use the following method.
Right click on drawable: new ->Image Asset
Select Launcher Icon in asset type
Select the path of the image you want to use as icon and keep the name as ic_launcher only.
next and finish.
You can customize it using the different checkboxes and options.
This should work for the launcher icons.
ps: not enough reputation to comment, so posting as a new answer. :/

The colored image turned to have no color and just a grey vector in drawable?

I have created a new Image Assets in the Drawable cus I need to insert a new image in my app, but every time I create a new image asset, the output turns to be no colour at all. I've attached the pic of it.
It's confusing and whenever I import it in my layout, it's just grey all over as you can see in the image. Why is it cus I can't find any ready solutions? Let me know if I'm overlooked.
I got the answer for my own question which I find it's useful for some who still do not know how to enable the Batch Drawable Import. It's easy and just need to download plugin and install. I've read that the latest version already has it and I've downloaded and reinstalled, but it didn't show as what I was expecting. The solution is to download and install it.
First, In Android Studio, go to Default Setting File --> Setting or you can simple Click the SDK Manager Icon
In the Default Setting, go to Plugins
In the search option, type Batch Drawable Import and you'll see there's Android Drawable Importer.
In my image, it's already installed, Click Install Plugin and just follow the instructions.
You'll have to restart Android Studio and try to create a new Batch Drawable Import and you'll find it there. ;) Thanks.
While creating a new asset in the drawable folder you need to set the
"Launcher icons"
in the
"Asset Type "
drop down
This will add the images in their original color and will not be greyed out. Also it is possible it adds the images in res/mipmap folder. You can move the images from mipmap folder to anywhere you want.
I Found the proper solution!
You just have to add this code where you created your NavigationView object!
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
//add the line below and your icon will display as your .svg file
navigationView.setItemIconTintList(null);
navigationView.setNavigationItemSelectedListener(this);
When you create a Image Asset as Action bar and Tab icons in the newer version of Android Studio(2.2) it is automatically converted into grey scale,Choose theme from the drop down default is HOLO LIGHT choose custom and you could be able to give the color code,but this works only for sketches kinda images
To get color code

Floating action button android change icon

I followed a template on android studio to create a navigation drawer app. As you know it creates an initial activity with a floating action button and the email icon in it. I just want to change it to a plus sign. Here is the problem. It turns out there is no plus sign available as the ones I can see in every single example ( There is just one I can use but then the plus sign color is green, and I want it white! ).
I followed this steps how to download Material icons , I get the icon ic_plus, and I put every single file in its correspondent folder ( drawables, drawables-hdpi... ).
Problem is when I try to use it here:
The name turns red as it can't find it. As I said, I copied all files one by one to its correspondent drawable folder. I even tried this drawable importer
but the same happen.
What am I missing? And why plus sign icon it is not shipped as default icon, as for example the e-mail icon is, as I can see it in every single app using floating action button? I use Android Studio 1.5. Thank you!
EDITED
Looks like images are correctly placed in correspondent folders because if I try to use it on menu bar, I can find it through #drawables/ . Still don't know why I can't do the same for the floating action button. Ideas?
Put your image in the drawable folder.
Use the design editor and when you click on the FAB scroll down to the src and click that little square button with 3 dots on the right side to pull up all your options. You should be able to search for the name of the icon you uploaded and select it from here.
I tried to type in my file name using text editor and it couldn't find my image either.

Categories

Resources