Any guidance regarding creation of folder for different density in android - android

I've created five folder for hdpi,mhdpi,xhdpi,xxhdpi,xxxhdpi,by using android srudio builtin option in these folder one file is working good on dofferent screen sizes but when I want to create new resource file in these folder that's not working what should I do.

Related

how to create a new resources in the mdpi folder in the xamarin

I feel irritating to develop the xamarin now since it is so not stable... i am intend to create splash screen for the android, however from what i seen from the xamarin documentation,however before i am able to achieve it, i need to add the resources to my project. Please see the following documentation
https://developer.xamarin.com/guides/android/application_fundamentals/resources_in_android/part_1_-_android_resource_basics/
from the beginning the resource folder has been done to create all the mdpi , ldpi those folder... they skipped to teach us how to create those resource folder, so in the end, i tried to create a new folder which is named as drawable-mdpi and put some icon into it. In the end the files and folder name does not exist in the Resource.Designer.cs.
In the end my resources is unuseable... Google no solution
Earlier Xamarin project template used to have all Drawable folders by default. Now the template just has the mipmap folders. You need to create all the drawable folders manually by Right Clicking Resources Folder > Add > New Folder. Give names as "drawable-mdpi" "drawable-hdpi" and so on. You can then add images to them by Right Clicking respective folders > Add > Add Files. If the Image's Id doesn't appear in Resource.Designer.cs file, it might be due to some build error already existing. Try cleaning and re-building. Either Resource Id will appear in Resource.Designer.cs or the already existing error will pop-up fixing which your issue will be resolved.
I realized those documentation is the xamarin old documentation, by the default the xamarin created those folder already, however i dont know why the xamarin don't show when we create the new project and i still dont understand why only create 3 density which is hdpi, xhdpi and the xxdpi, is it the mdpi not longer use? I have no idea. However i will need to add those folder again in the project so i am able to see it.

Loading local images in React Native Image component

i'm working on an application with react native on android. i would like to put some Image components on the screen and load them with some local image files. can someone provide the directory (relative to the project's root directory) in which i should place my files ? the docs don't seem to provide any useful information on this.
From the example here:
https://facebook.github.io/react-native/docs/image.html#adding-static-resources-to-your-android-app
Adding Static Resources to your Android app Add your images as bitmap
drawables to the android project (/android/app/src/main/res).
To provide different resolutions of your assets, check out using
configuration qualifiers. Normally, you will want to put your assets
in the following directories (create them under res if they don't
exist):
drawable-mdpi (1x)
drawable-hdpi (1.5x)
drawable-xhdpi (2x)
drawable-xxhdpi (3x)
If you're missing a resolution for your asset,
Android will take the next best thing and resize it for you.
NOTE: App build required for new resources Any time you add a new
resource to your drawables you will need to re-build your app by
running react-native run-android before you can use it - reloading the
JS is not enough. This process is currently being improved, a much
better workflow will be available shortly.

How do you add the same images of different pixel densities to the drawable directory (android studio)?

I am following the tutorials in the Big Nerd Ranch book for android but that book is structured for Eclipse + ADT.
I am trying to add an arrow icon to a button and I have folders (drawable-hdpi, drawable-mdpi, drawable-xhdpi) that contain sets of identical images. Ideally I would like these folders to appear in the drawable folder but whether I copy and paste or drag these folders it doesn't seem to work. They appear in the packages section instead, but when this happens I can't seem to reference them from xml files in the layout folder.
The best I can do is drag/copy the files (not the folder)into the drawable folder, in which case they stay there and I am able to use them. The problem with this is I can have, at most, one pixel density for the set of images that is in there. The only way I can think of is if I change the names of all of them so that the problem of overwriting is gone.
However in the mipmap folder in the ic_laucher.png folder there are four files of the same name, except there are greyed out density descriptions beside them. How is this done?
What should I do?
As you can see I have now added the images using the file system. I am still unable to reference these using the resource name however. I am still not sure why.
What you are seeing in the mipmap "folder" is just some UI magic. The Android project view in Android studio will combine all resources with the same name into a single entry like you are seeing for ic_launcher.png to make it easier to view your resources.
Behind the scenes, this still uses different folders on disk. If you open up your project in Windows Explorer, you will see separate folders for mipmap-xhdpi, mipmap-mdpi, etc.
The same is true for your drawable folders. You still want to keep your images in separate density-specific folders on disk. Android Studio will then display them to you as if they were all in the same drawable folder in the Android project view. You cannot physically move your density specific folders beneath the drawable folder.

android: How can I create subfolder in a `mipmap` folder, that can be accessed in code and layouts

I have my image resources in the various mipmap folders (mipmap-xhdpi, mipmap-xxhdpi, etc.) My project has hundreds of images (and growing) and it is becoming cumbersome that they are all in a single level in each directory.
I want to create a subfolder, such as "sprites" that I can reference in code with something like
R.mipmap.sprites.sprite_name
How can I create usable sub-folders in my mipmap folders?
When I create a new directory inside of a mipmap folder (using New -> Directory), the directory and its contents are invisible to anywhere that I am specifying a resource, namely:
• In the design-view of my xml layout, when I am browsing for an image resource for a background or an image button, the sub folders are hidden.
• In code, when I am specifying an image resource (R.... the subfolders are ignored).
Is there a correct way to do this? There appear to be some other directory options, Under the New -> Folder category, I have:
• Assets folder, described as "create a source root for assets to be included in the apk," but I don't want a root, I want a subdirectory.
• Res Folder, "source root for android resource files" 1. I don't see how this is different than an asset and 2. again, I don't want a root.
There are also several other folder types listed, that I am not familiar with.
If this cannot be accomplished, what is the correct way to include (and organize) hundreds (or thousands) of image resources in a project? Is the only way to do it really to have them all in a single directory?
How can I create usable sub-folders in my mipmap folders?
You can't. Resource directories of any time, mipmap or otherwise, cannot have subdirectories.
what is the correct way to include (and organize) hundreds (or thousands) of image resources in a project? Is the only way to do it really to have them all in a single directory?
If you are going to go with resources, then yes, though I would put them in drawable directories. mipmap is mostly for launcher icons.
the mipmaps are special because the app will display images of a different resolution depending on the device resolution
No. mipmap and drawable resources support resource resampling at runtime, but it is based on density, not resolution.
As ByteHamster notes, you can put whatever sort of directory structure you want in assets/, though you will need to put the appropriate values into BitmapFactory.Options to help with the resampling based on density.
Yes, you must keep all the resources in a single folder because, as you may know, different folders are used to target different device classes.
The right way to organise your resources in by prefix: as stated in the official Android documentation, you should use prefixes to make the resources appear in a meaningful order.

working with assets folder or drawable folder

I am creating an app using android studio.
i created the assets folder and created sub directories under it for each activity i am using (each one has a different set of images).
But on the other hand i want to support multiply screen resolutions which as i read is supported using drawable folder's, also drawable doesn't support sub directories.
I am using API 19 at the moment.
Putting all the images in drawable folder will be a bug mass.
How can i achieve my goal of order in my images and supporting multiple screen resolutions
Thank you in advance
there are subfoldes in drawable. take a look at this http://developer.android.com/guide/practices/screens_support.html
The drawables folders allow you to save various resolution versions of an image into separate folders. The OS will choose the right asset based on the device screen density for you when you ask for #drawables/image_name. /assets is more like a normal file directory. In general if you pull from assets you need to handle resolution differences on your own.

Categories

Resources