How to import multiple vector drawables to Android Studio project - android

I used https://inloop.github.io/svg2android/ to convert 50+ SVG's to XML as suggested in this answer. Now I have a .zip containing all the XML files. Where do I put them to be able to use them in Android Studio?
I know I can import one by one but that's what I'm trying to avoid in the first place.

Just put the xml files in drawable folder, and you will be able to retrieve them using R.drawable.names

Related

Is it possible to create multiple directories for drawable in res?

So I have tried creating new directories by right clicking the res folder then on new--> Android Resource Directory.Then I changed the Resource Type to drawable.
After doing all that I copied my images into this new directory that I have created and when I try to assign them to an imageview that was not assigned yet an image through the xml with the command android:src="#mydir/mypic" android studio does not recognise my custom folder name. Is this even possible?
I am using android studio 2.2.3
You can't create subfolders for drawables in the res/drawable folder.
See this question here in SO.
Can the Android drawable directory contain subdirectories?
#Aris I think it is possible to create multiple directories using gradle,
I read on mediumn about Android Project Structure - Alternative way
Please check this link,
https://medium.com/google-developer-experts/android-project-structure-alternative-way-29ce766682f0
Please read Conclusion carefully.
Thanks

How to use drawable resource from library module in to our application module?

I am using android studio 2.1.3,
i have import compile 'com.android.support:appcompat-v7:23+'. Now i want to use images from appcompat library in my application module. Please give reply as soon as possible.
I have attached screenshot. Please check image.
You cannot do that.Most of the resources in appcompat library is private.This library has public.xml in res/value of it and only the resources defined in this xml are accessible and the rest of the resources are implicitly private and android wouldn't give you suggestion to use them.Your best bet is to download a copy of it and put it in the drawable of your own application so you will be able to refer to them.
Resource: https://developer.android.com/studio/projects/android-library.html
For xml-
Make an imageview.
Write this inside the image view-
android:src="#drawable/name"
and it shall work
So now click on the clip art icon and there are hundreds of icons and pics. They are probably the same as of the external libraries. Click next for whichever image you want and that will be added to your drawable folder and then you can use it.
Add imageView in xml and add background.
android:background="#drawable/any_image_you_want"

Sharing resources between projects

I have many projects that have an identical activity which include identical drawable resources. In each project I have duplicated the src java file, the layout xml file and the drawable images.
Ideally I'd like to be able to have one set of these and somehow share them to the other projects. Shared folders appear to be the way to go but after setting them up I cannot figure how to reference the linked files.
Lets say, to keeps things simple, I have two projects, a Source project which contains the java code file, the layout file, and a drawable folder containing all the images I require.
The second project lets call it Destination.
In Destination I create the linked folder called "linked" to the drawable folder in Source which is then viewable in explorer. In my layout xml, how can I reference the "linked" folder and then the individual images for the SRC of imageviews?
Would it also be possible to link my identical activities java source and xml files in the same manner?
If there is another or better way to accomplish this I'd be grateful for some pointers.
thanks
I think you should package your common code and resources into a library and then use this library inside all yours projects.
What you want to do is to add a folder to your project build path.
Here's how I do it in Eclipse:
Right click on the project in the Project Explorer
Properties > Java Build Path > Source > Link Source > Choose the folder
Hope this helps (:

R.layout shows only Android default template proposals.

I have a couple of xml files in my layout folder but when I use them in my class the template proposals doesn't show my layout files but shows android default proposals. There seem to be no error in any of my files at all. I tried deleting the R.java file and rebuilding and restarting eclipse but nothing seems to be working. PLease help. I need to get this done asap :(
Thanks,
Sowmya.
This may be because, when you try to use your xml layouts, the default android R file is imported.
import com.android.R
Check that. If it is there, delete that import and import the correct R file which starts with your package name.
First look are you setting xml name fine like
e.g
you have your.xml
Then in onCreate
super.onCreate(savedInstanceState);
setContentView(R.layout.your);
Then clean your project.
if you have design multiple xml with same name then you must have to place them in appropriate folder using hdpi etc
Further details available here
or you can write
import.R.layout
It will work for sure

Android: Refactoring XML files in Eclipse?

Is there a way to easily rename XML files in Eclipse while developing for Android so that these changes are reflected in source code?
Right-clicking on the file in package view and selecting refactor->rename changes the file's name, but does not alter references to the file within the .java source files.
I realise this is an old post, but i was trying to do the same and just came up with a solution to this in eclipse:
Search -> File Search -> Replace...
Replace:Current.Style.Name
With: New.Style.Name
Thats it! Nice and easy, i didn't want to deal with the hassle of going into all my xml layouts and changing them.
I do not think such a thing exists for Android resources directory let alone layouts. You have to change the references manually.

Categories

Resources