How to add a texture file to an Android Studio project - android

Many examples use the resources infrastructure to load textures. I'd like to debug a problem, so I want to use the most simple, complication-free solution.
When I try to add an image asset to my project (with New > Image Asset) I'm getting the usual GUI, which will generate HDPI, XHDPI etc. versions. This is clearly not intended for textures. - So what is the right way?

Most app stores texture and background images in asset folder. If you want to store it in the resources only then you can use drawable folder.
For layout problem you can choose Project from dropdown and choose the folder.

Related

How to mass import/update Android drawables (in PNG format) and overwrite previously converted WEBP drawables?

I have approximately 100+ drawables in my Android project, and recently received updates to 33 of the drawables in PNG format. Normally my workflow is to merge/replace the drawable-... folders to replace drawables that have updates, and retain other drawables that do not need to be updated. This works well when the files are of the same type (all PNG), but recently in an effort to slim down the app, we converted in AS the entire drawable directory to WEBP (lossless). Now when I do merge and replace with updated assets, both PNG and WEBP versions of the same drawables are retained, which causes build failures on every duplicate drawable.
I have tried the "Convert to WEBP" option in AS on the entire merged drawable directory, but this does not attempt to convert the drawables that have existing WEBP files, leaving duplicates all over.
Any suggestions on solutions (aside from manual remove, replace, rename, etc on individual files) would be greatly appreciated!
NOTE: I am asking the design team if they can just give us WEBP files instead, but they are on vacation this week so I was hoping for another way!
I found this type of solution, I hope this goes well for you.
Instead of put new images with webp extension inside the drawable folder, why dont you convert the png images in webp images inside android studio?
This is what you have to do:
select all your images at once
right mouse click
convert to webp
now please attention: uncheck only the "skip images with transparency/alpha channel...",
the rest leave it unchanged
click next for your N images and click finish
now you have replaced all your PNG images with WEBp images
hope this works well for you

How do i move images from Mipmap to Drawables and retain their size in Android?

I am just getting into an android project that someone else already worked on. I am currently just correcting UI issues and such, and we decided we needed bigger sizes of some graphics that look blurry on tablet size. So we decided to make a few size-dependent folders.
Until now, former guy has placed a lot of graphics into the mipmap folder because it automatically selects images based on density. But now i read that mipmap is only for the launcher icon.
Now my dilemma is whether I should move the graphics or not. It wouldn't be too hard to do, but i tried with a few, and I noticed that when taken out of the mipmap folder, and placed inside the drawables folder, the graphics are suddenly bigger. This means that I either have to resize every single graphic, or replace the file with a smaller version.
I am tempted to leave well enough alone, and not invoke all sorts of re-design processes for the sake of keeping the structure tidy. But on the other hand, it kinda hurts not to.
Does anyone know what I should do, or if mipmap is ok to use for graphics that aren't the launcher icon? And if I am to move it, how do I best tackle all these problems?
Ideally, you would have larger images which are then used accordingly in the relevant drawable folders. Android takes care of resizing these automatically. This is also the reason why the images you have in the minimap folder are being enlarged when exported to the other folders.
If I were you, I would leave the graphic files in the same folder as the previous developer set them. Otherwise you will be getting pixelated images.
The other option would be to use an image-editing software to enlarge the images and copy them to their respective folders.
In the end it is up to you, but if as you are saying, there are many images, I would leave them where they are.
mipmap is ok to use for graphic.in eclipse their are drawables folder to place images but in android studio project mipmap folders are default folder and you can put any type of images it will automatically adjust according to size but put 9paches image in that folder

where drawable-hdpi ,drawable-mdpi ,drawable-xhdpi and drawable-xxhdpi. go?

before when I was creating a new project I was found this folders drawable-hdpi,drawable-mdpi, drawable-xhdpi, and drawable-xxhdpi. but now they are all gone!
is there any explanation of what happens?
and where we should put our images?
This is perhaps because they will add an Gradle plugin that converts SVGs to PNGs during build (as mentioned in this IO talk). The idea is that you will only need to have a single SVG instead of multiple PNGs for various densities (an thus, only one drawable folder). You can still create the folders and use PNGs.
The Gradle plugins for SVG conversion by Google has not been released yet, but you can use Victor or a similar plugin if you already want to use SVGs for your drawables.
You should read Android Blog
you can just create drawable-xhdpi.
I just give answer here
read and if any problem ask.
I wasn't aware that Android Studio ever provided these dpi dependent drawable folders for the built-in default project scaffolding, and indeed, why should they?
Are they supposed to guess that you're going to support each and every one of these resolutions? Perhaps all your graphics will be vector graphics? Perhaps you only target low or high resolutions?
Also, the DPI modifier is only 1 of the possible modifiers you can attach to a resource folder. You can also add locale, screen width / height, mobile country code and many more. Should Android Studio create a folder with each of these options, along with every possible variation? You'd end up with thousands of folders which you'd likely never use.
In addition, creating a folder with no assets inside it is a big problem when you start synchronising your code using Github or something similar, and creating every possible folder with default assets inside seems like a huge waste.
I think the best approach here is to create any resource folder you need when you need it. Google leaves this decision to you.
Also, important: There is no XDPI or XXDPI folder - it's XHDPI, and XXHDPI
Check in your project section, Not in android section, If they gone just simply create them

Can Eclipse automatically generate different DPI images for Android projects?

I'm trying to import a 600x600 PNG I made into my Android project so that I can use it as a full-sized image in an Activity. Dragging and dropping it onto my /res folder just puts it in that folder, which of course generates an "invalid resource directory name" error.
I can drop it into any of the /res/drawable folders and that works fine, except then it's only in that one folder.
Surely, there's an inbuilt tool which can take my image and scale it appropriately for each /res/drawable folder.
AFAIK there isn't.
What you can do though, is use the drawable-xhdpi folder only. Android will automatically scale down for lower dpi.
The only exception is the launcher icon. You will have to provide all sizes (don't forget xxhdpi for tablets!).
You can find the needed sizes in the Icon Design Guidelines.
It is important to note that the ADT plugin does have tools for generating some icons sets, such as Launcher icons, Actionbar icons and Notification icons.
These tools can be accessed by opening the New wizard (Ctrl + N) and double-clicking Android Icon Set in the Android category.
there's an inbuilt tool which can take my image and scale it appropriately for each /res/drawable folder.
For the scaling part, check out the Icon Generators Tools # Android Asset Studio. There are tools for generating Launcher icons, Tab icons, Action bar icons and (in your case) Generic icons.
Luckily this changed - you are now able to autogenerate different densities - take a look at:
https://code.google.com/p/android-drawable-converter/
If you put your drawable resources in /res/drawable, that resource will be used for all devices.
However, it probably won't do exactly what you want. I would recommend scaling the assets yourself. If that isn't a viable option, then you are stuck with letting Android do the scaling for you.

Generate of all drawable sizes from one (large) image automatcly

I am investing some time doing drawables for an Android project and I am looking for alternatives.
Currently I do them on Adobe Illustrator and with some drawables I can use Android Asset Studio (e.g. drawables for the action menu). The problem with Android Asset Studio is the lack of possibilities to use my own color (we can only use white/black colors).
I wanted something like Android Asset Studio where I can give him a HD image and he creates all drawable sizes. Is that possible?
Another option could be a program/script that could allow me to say "I want to scale to these resolutions" and he does it for all images.
What you're looking for is called a batch resizer, but without knowing what you're working with, it's hard to give a recommendation. For instance, you can use both Photoshop and Gimp for it. I believe Gimp will require a plugin, while Photoshop has the script built-in.

Categories

Resources