Using a png as a button in Android studio - android

I would like to use a png as a button in android studio. I tried adding the png into the drawable folder in my android project folder, however, when I open my android studio under res there is only one drawable folder with 4 launcher.png and no matter how i try to copy my png in there (over windows folder or directly over android studio) it doesn't work and won't show up. Furthermore, how do I use the png as a button in the xml layout?
Thanks in advance!

Click on the drawable folder, right click, select import and navigate to the png directory, select the .png file. If that doesn't work, then there is something wrong with your project or eclipse.
As for using it as a button, google has plenty of examples.

I am using Android Studio, so I selected optimize imports and then it shows you the folder path. I copied the png in there and hit run after clicking optimize imports now it's there .

Related

How I fix NOTHING TO SHOW in my vector asset in android studio

I want to add a new vector asset. I am trying to add a clipArt but it only shows in the dialog box "Nothing to show". No icon is showing and I want to add an icon. I don't know to fix this. Please help. I am still trying to learn android studio and I am practicing on how to use it.
For myself, my asset dialog only shows some of these icons. And here is my solution.
Go to
[SdkPath]/icons/material
There should be a file called icons_metadata.txt, and folders
materialicons
materialiconsoutlined
materialiconsround
materialiconssharp
materialiconstwotone
For each icon, there will be one folder in the folders above. For example, we have materialicons/share, materialiconsoutlined/share and so on.
These icon folders are not complete, only icons starting with digits exist. Since the folder only updated when "Select Icon" dialog is opening, I opened "Select Icon" dialog again, waiting for all icons are downloaded, and then reopen the dialog.
Then my problem is solved.
This a new problem introduced in the latest version of Android Studio 4.1.
This happens when your windows user name folder contains a space. Rename your user name’s folder removing the space and it will work again.
For some reason the space make the folder where the icons are located not visible to Android Studio.
If there are already this folders and still nothing in dialog try deleting <sdk>/icons/material/icons_metadata.txt
Credit to
#MainActivity
Those clip arts are located in "icons" folder inside your sdk folder on your hard drive and the sdk folder is generally this:
C:\Users\ --username-- \AppData\Local\Android\Sdk
I guess android studio cannot access the right sdk location so make sure the sdk location in your "File/Project Structure/SDK Location" matches the actual sdk location on your hard drive.
Alternatively, you can download the clip art you need from this link: Android Material and import them by choosing Local file in your Asset Studio.
In Android Studio 4.1.1 this issue is resolved. Update if possible.
It's working
Your SDK folder name must be spaced less, ex- (UTTAM, UttamSdk, Uttam_sdk)
HAPPY CODING :)
Same thing happened with me, also i was not able to change my user name because of Win 10 Single Lang. so i just moved my SDK folder to another path but there was not space between the path like from >> C:\Users\User Name\AppData\Local\Android\Sdk to >> C:\Users\Sdk.

Correct drawable folder for SVG assets

I assume the correct folder is drawable-nodpi.
I just need to know this so that I can set up PNGexpress in Photoshop to generate the folder automatically (on asset export) and know that im not forcing my developers to move the files around a bunch on their end.
Fire and forget type approach - best to be sure than assume though!
Thanks!
If you create the SVG from inside of Android Studio it puts the file inside the drawable folder. You can check it here: https://developer.android.com/studio/write/vector-asset-studio.html in the 7 step of the section "Adding a material icon".
So, with this, I would choice to use the drawable folder to keep the same behavior as Android Studio.

When I create a directory in my res folder in android studio, it doesn't appear? even after refreshing

So in my project view I have only a drawable file. I'm following a book tutorial at the moment and it has drawable-ldpi etc. so to avoid confusion I thought I'd crate them too. The problem is that when I created my drawable-ldpi file, it simply didn't appear in my res folder, even after refreshing an restarting android studio.
I tried to create it again, and it says the directory already exists. What am I doing wrong here? why aren't the directories I've created appearing in my res folder?
EDIT - Android project tree
From the top left corner, just above App folder, where you see Android - with dropdown icon. Click on it and select project file from drop down options.
You can also select "Project"

Android Studio shows old Image Assets

When I overwrite an image asset in Android Studio, for example the default ic_launcher, the IDE keeps showing the old image - no matter what I do, the image is never refreshed in the IDE (the deployed app uses the correct one). After a while you are not sure which files you have already changed and which are to be changed. You can prepare a list and check the items, but it would be nice to see the actual files in the IDE.
Is there any way to force this incredibly buggy IDE to 'sync' the cached image resources with those actually chosen by the developer?
I am using Android Studio 1.1.
Cheers
Open your src/drawable folder and make sure that this ic_launcher is not in any folder of your drawable, it means that in your mdpi, hdpi, etc... folder is this icon, then you can delete it in each folder on your drawable or you can replace it with yours (with the same name, if you don't want to replace the ic_launcher on the whole code), and Clean / rebuild the project.

Android Setting Background

I'm trying to change the background of my first app to a png I have. I put the png in a newly created folder called "drawable." When I go to browse my "drawable" I can't see it's "children" or files. The only error of sorts that it gives me is "You must... rce item" anyone run into this? Android API 7 by the way.
Put the png in /res/drawable and then do a clean on your project in eclipse to force the .R class for your app to be recreated. You might also need to do an f5/refresh in eclipse on the project to get it to see that you have added a file in filesystem to /res/drawable.

Categories

Resources