Unknown Error in drawable folder - android

Am create an app that integrating zxing. I followed as per this site http://damianflannery.wordpress.com/2011/06/13/integrate-zxing-barcode-scanner-into-your-android-app-natively-using-eclipse/. Now i have error in drawable folder. Please guide me.
Thanks in Advance.

As you are dividing according to density to achieve multiple size support inside your android app.
But there ain't any xxhdpi.
ldpi Resources for low-density (ldpi) screens (~120dpi).
mdpi Resources for medium-density (mdpi) screens (~160dpi). (This is the baseline density.)
hdpi Resources for high-density (hdpi) screens (~240dpi).
xhdpi Resources for extra high-density (xhdpi) screens (~320dpi).
nodpi Resources for all densities. These are density-independent resources.
tvdpi Resources for screens somewhere between mdpi and hdpi; approximately 213dpi. This is not considered a "primary" density group. It is mostly intended for televisions and most apps shouldn't need it—providing mdpi and hdpi resources is sufficient for most apps and the system will scale them as appropriate.
There's no need of drawable-xxhdpi inside res/ of project. So please remove it.
For more details follow up these configuration qualifiers

Related

What is the smallest possible screen size that will use sw-600dp layout?

I created layout-sw600dp/layout.xml and it was looking great on device A. But on device B this layout has melt and looks bad. I want to know how my layout looks in worst possible case scenario (exactly 600dp width screen)
I want to create emulator with that screen size, so I will 100% sure that my layout will be looking good on sw-600dp+ phones. Do you know what size it is?
Also, I would really appreciate and be happy if you could give me an advice how to support multiple screen sizes in a modern world.
P.S. I have pretty difficult layouts with 40+ buttons
The short answer to your question regarding the type of emulator you'd use for sw-600dp+: a 7" tablet. You can find more information here. The sw in sw-600dp is the smallest width qualifier. It means that it is only mean to be used for devices with 600dp, which is typically 7" tablets.
The longer answer to your question about how to make sure your app look good "in a modern world" is:
Rather than trying to figure out what is the "worst case scenario", you should design layouts for each of the different screen densities and device types that Android supports:
ldpi Resources for low-density (ldpi) screens (~120dpi).
mdpi Resources for medium-density (mdpi) screens (~160dpi). (This is the baseline density.)
hdpi Resources for high-density (hdpi) screens (~240dpi).
xhdpi Resources for extra-high-density (xhdpi) screens (~320dpi).
xxhdpi Resources for extra-extra-high-density (xxhdpi) screens (~480dpi).
xxxhdpi Resources for extra-extra-extra-high-density (xxxhdpi) uses (~640dpi).
Per the Android docs:
To create alternative bitmap drawables for different densities, you
should follow the 3:4:6:8:12:16 scaling ratio between the six primary
densities. For example, if you have a bitmap drawable that's 48x48
pixels for medium-density screens, all the different sizes should be:
36x36 (0.75x) for low-density (ldpi) 48x48 (1.0x baseline) for
medium-density (mdpi) 72x72 (1.5x) for high-density (hdpi) 96x96
(2.0x) for extra-high-density (xhdpi) 144x144 (3.0x) for
extra-extra-high-density (xxhdpi) 192x192 (4.0x) for
extra-extra-extra-high-density (xxxhdpi) Then, place the generated
image files in the appropriate subdirectory under res/ and the system
will pick the correct one automatically based on the pixel density of
the device your app is running on:
res/ drawable-xxxhdpi/
awesome-image.png drawable-xxhdpi/
awesome-image.png drawable-xhdpi/
awesome-image.png drawable-hdpi/
awesome-image.png drawable-mdpi/
awesome-image.png
You would do the same thing for layouts, creating a specific layout for each of the various dimensions (be sure to put the layouts in the right directories: layout-xhdpi, layout-mdpi, etc.). Doing this will allow the device to select the correct image/layout based on the device the user is using.
If you have a 40+ button layout, you would create buttons for each layout using the above method, then create layouts for each device. It's tedious work, but it is the correct way to do layouts on Android devices.
TLDR; read the Android documents around supporting multiple screen sizes.

In which drawable resource file should I place an image based in the pixel size?

I have 3 images with the following sizes in pixels (I got them from Get Info)
300x200
150x100
600x400
Question: How do I know in which resources directory (hdpi|mdpi|xhdpi etc) I should put them?
There are 8 folders available, and each one varies depending on pixel density:
1. lpdi - Resources for low-density (ldpi) screens (~120dpi).
2. mdpi - Resources for medium-density (mdpi) screens (~160dpi). (This is the baseline density.)
3. hdpi - Resources for high-density (hdpi) screens (~240dpi).
4. xhdpi - Resources for extra-high-density (xhdpi) screens (~320dpi).
5. xxhdpi - Resources for extra-extra-high-density (xxhdpi) screens (~480dpi).
6. xxxhdpi - Resources for extra-extra-extra-high-density (xxxhdpi) uses (~640dpi).
7. nohdpi - Resources for all densities. These are density-independent resources. The system does not scale resources tagged with this qualifier, regardless of the current screen's density.
8. tvdpi - Resources for screens somewhere between mdpi and hdpi; approximately 213dpi. This is not considered a "primary" density group. It is mostly intended for televisions and most apps shouldn't need it—providing mdpi and hdpi resources is sufficient for most apps and the system will scale them as appropriate. If you find it necessary to provide tvdpi resources, you should size them at a factor of 1.33*mdpi. For example, a 100px x 100px image for mdpi screens should be 133px x 133px for tvdpi.
To create alternative bitmap drawables for different densities, you should follow the 3:4:6:8:12:16 scaling ratio between the six primary densities. For example, if you have a bitmap drawable that's 48x48 pixels for medium-density screens, all the different sizes should be:
36x36 (0.75x) for low-density (ldpi)
48x48 (1.0x baseline) for medium-density (mdpi)
72x72 (1.5x) for high-density (hdpi)
96x96 (2.0x) for extra-high-density (xhdpi)
144x144 (3.0x) for extra-extra-high-density (xxhdpi)
192x192 (4.0x) for extra-extra-extra-high-density (xxxhdpi)
You can have even more information from Android official documentation
Copy image and paste to drawable folder.
You can add image by using .xml file
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#drawable/image_name" />

Are these layouts enough to scale images for smaller DPI devices?

Make copy of main activity file in the following folders.
res/layout/main_activity.xml
res/layout-w600dp/main_activity.xml
res/layout-large/main_activity.xml
res/layout-xlarge/main_activity.xml
And resize my images from drawable and place them into these folders
ldpi (~120dpi).
mdpi (~160dpi).
hdpi (~240dpi).
xhdpi (~320dpi).
xxhdpi (~480dpi).
xxxhdpi (~640dpi).
Is this enough to make my app scale properly for phones with lower resolution?
yes, after a lot of experimentation the layouts seem to work, all I had to do was make seperate folders for them.

How Android choose between screen density

For example, I provide some image in ldpi, mdpi and xhdpi folder.
When I run app on device with hdpi density, which resource will it pick - ldpi or mdpi?
Taken from http://developer.android.com/guide/topics/resources/providing-resources.html#BestMatch
If no matching resource is available, the system uses the default
resource and scales it up or down as needed to match the current
screen size and density The "default" resources are those that are not
tagged with a configuration qualifier. For example, the resources in
drawable/ are the default drawable resources. The system assumes that
default resources are designed for the baseline screen size and
density, which is a normal screen size and a medium-density. As such,
the system scales default density resources up for high-density
screens and down for low-density screens, as appropriate. However,
when the system is looking for a density-specific resource and does
not find it in the density-specific directory, it won't always use the
default resources. The system may instead use one of the other
density-specific resources in order to provide better results when
scaling. For example, when looking for a low-density resource and it
is not available, the system prefers to scale-down the high-density
version of the resource, because the system can easily scale a
high-density resource down to low-density by a factor of 0.5, with
fewer artifacts, compared to scaling a medium-density resource by a
factor of 0.75.
In this case android chooses **mdpi*.
You can read more about How Android Finds the Best-matching Resource
Consider MDPI is 1. Then, LDPI is 0.75 and HDPI is 1.5. What that means is that if you have a drawable that is, say, 50x50 on a MDPI screen it will have to be ~37x37 on a LDPI screen and 75x75 on a HDPI screen.
If you do not supply special drawables for each density, Android will scale the closest one available automatically.
You should not consider the DPI of a device to have anything to do with screen size and/or number of pixels and/or resolution and/or aspect ratio. A device could be very small and have an HDPI screen or very large and have an LDPI screen
ldpi Resources for low-density (ldpi) screens (~120dpi).
mdpi Resources for medium-density (mdpi) screens (~160dpi). (This is
the baseline density.) hdpi Resources for high-density (hdpi) screens
(~240dpi). xhdpi Resources for extra-high-density (xhdpi) screens
(~320dpi). xxhdpi Resources for extra-extra-high-density (xxhdpi)
screens (~480dpi). xxxhdpi Resources for
extra-extra-extra-high-density (xxxhdpi) uses (~640dpi). Use this for
the launcher icon only, see note above.
please check http://developer.android.com/guide/practices/screens_support.html and SO answer https://stackoverflow.com/a/6373533/2826147

How to define different style for same layout according to screen size?

How to define different style for same layout according to screen size.
Is there any way to define such thing, except from different layout folder for different screen size.
I haven't found any other way to support different screen.
Use different folder for different screen resource:
ldpi Resources for low-density (ldpi) screens (~120dpi).
mdpi Resources for medium-density (mdpi) screens (~160dpi). (This is the baseline density.)
hdpi Resources for high-density (hdpi) screens (~240dpi).
xhdpi Resources for extra high-density (xhdpi) screens (~320dpi).
You better have a look here.
You can have different values folder as you have different layout folder
such as values-large, values-land, values-large-land

Categories

Resources