hi guys i am having a bit of a hard time i have an android application that uses image buttons in the display so far i have been testing on the same device however when i install it on certain devices some of my icons are not visible doe it still occupies the same space and if you click on where they are suppose to be they still trigger their intended actions i am using png images in the recommended dimensions/densities saved in the drawable folders
36x36 for low-density (LDPI)
48x48 for medium-density (MDPI)
72x72 for high-density (HDPI)
96x96 for extra high-density (XHDPI)
180x180 for extra extra high-density (XXHDPI)
192x192 for extra extra extra high-density (XXXHDPI)
plese let me know how to resulv this
use low dimension images
Reason, when rendering image on Screen OpenGLRenderer was not loading bitmap for high resolution devices and hence no image was coming on nexus devices.
please refer :- Android Lollipop not showing android:background image
please let me know if it is dose not work for you.
Related
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.
I am creating to show virtual card swipe view for left to right and right to left. so, am trying to give common width & height(xxxhdpi-values dimen.xml) for below mentioned mobiles in Android UI part.
Samsung Galaxy note plus
6.8 inch, 1440*3040 , 498 PPI.
Google Pixel XL3 Android Mobiles.
6.3 inch, 1440w*2960h , 523 ppi density.
both detecting xxxhdpi values folder. so, If I given common width dp values. then, both screen design showing different card UI alignment. UI is not properly fit with the screen in both devices.
so, If I am trying to adjust Samsung device, google pixel design will get collapse/not fit.
so, am thinking, this is the good solution one like I want to create separate values folder for this two devices.
very long back, I have this solution. please find the link below:
How to Create Seperate Values folder Sony Xperia Z1 in android
Ex: I tried for this Samsung: (its detecting in xxxhdpi-values folder(640dpi)).
dp=px/(dpi/160) so, dp = 1440/(640/160)=360 . so, I we got values-sw360dp.
Exactly, I dont know, this method is correct or not, nowadays.
I referred this links also. but, still am not clear idea.
Different values folders in android
How to define dimens.xml for every different screen size in android?
can anyone please help/suggest any alternate/better solution on this UI issue.
It maybe help for more android developers also.
Thanks Advance.
Reference: support different pixel density:
https://developer.android.com/training/multiscreen/screendensities
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).
I have always issue with screen compatibility, i am creating one layout for all type screen. I am using all 5 type mipmap/drawable for images.
The issue is when i ask to my designer for icons they are asking me for size. i am following below link for all type images
https://developer.android.com/guide/practices/screens_support.html
Still not getting correct icons for all type screens.
36x36 (0.75x) for low-density
48x48 (1.0x baseline) for medium-density
72x72 (1.5x) for high-density
96x96 (2.0x) for extra-high-density
144x144 (3.0x) for extra-extra-high-density
192x192 (4.0x) for extra-extra-extra-high-density
those size looking big in phones.
It would be very much helpful if anybody can specify the size for different screens.
Thanks
Android Studio gives those features where you can create all 5 different size icons.You need to follow below step:
right click on drawable then >new >Image Asset>
From 2nd image select image option and select your icon from desktop/laptop and android studio will generate all 5 mipmap/drawable type icons.
you can also try with this link
https://romannurik.github.io/AndroidAssetStudio/icons-launcher.html
Happy Coding!!
This way you are creating icons with size 48dp x 48dp - they are big. I suppose you want 24dp x 24dp (that is 24px x 24px for medium-density).
Do you know this tool?
https://romannurik.github.io/AndroidAssetStudio/icons-launcher.html
And be sure to put those icons in correct folder...
medium-density in drawable-mdpi, high-density in drawable-hdpi and so on.
The best way to import icon is using image assets:
right click on drawable then >new >Image Asset>the by selecting image type and image location you can easily add icons :)
make sure this should be used in case of icons only
Hi in the below layout icon displaying small and as well as icons not occupying full screen.I want to occupy the icon in full screen and icon should be in bigger size.!
If I am using small mobiles it occupying full screen and icons also displaying correct size.when I am installing my app in this device it's giving two problems.
Can any one help me from this issues.
Thanks in advance
Check the official documentation for explicit information.
Any android phone has one of this six screen densities.
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.
Create icons of different sizes for different screen resolutions and put those icons to yourProject/app/src/main/res/drawable-mdpi or -hdpi or -xhdpi or -xxhdip folder.
I believe the issue here is that even though the tablet has high resolution, it still has low density due to its large screen size. So, the tablet is picking the image from low density folder which makes it look small on large scree.
The discussion here sheds some light on the issue. Basically you are required to create separate drawable folders for tablet's width. Ex. drawable-sw600dp and drawable-sw720dp etc.
Refer developer guide for more details.
I want to change the color used to indicate a selected radio button. I've found an explanation of how to do so. The only thing I'm missing is a source of images to use. To maintain a consistent appearance I want to take the existing images that are used by default and just recolor them. I've seen a guide explaining to get the images in the past, but when I try searching I'm unable to find it.
You can find the images as part of the SDK:
x:\path\to\SDK\platforms\android-17\data\res\drawable-mdpi
The images from the radio button beginns with btn_radio.
As cafelatte notes you need to provide the 4 differnt densities. There are four types:
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).
Either create your own resources, or pull what you need from the SDK.
In ${your-sdk-dir}\platforms\android-${apilevel}\android.jar
Simply take the resources you need from under the res\drawable* subdirectories. Don't forget to provide [l/m/h/x]dpi resources if required.