Reputation: 542
i have one app which can be runs on different screen size from 3.7 Inches to 6.0 inches(no plan for tablet now).
now i have TextView which have 17dp for title and 14dp description. but when i run the app in small device (3.7-4.7 inches screen size device) the textview's text is big.
But the same textview in higher 5.5 or 5.7 this can be small .
so how can i make TextView looks same for all device.
Upvotes: 1
Views: 2447
Reputation: 31
As screen size is between 3.7 and 6.0 you should only create 1 additional dimens files like sw480 and use dp-s for TextView dimensions and sp for text size. In default dimens file you should write sizes for devices with smallest screen sizes e.g. for 3.7‘, and comparably bigger dimens in sw480 file e.g for 5.5‘ screens. Based on particular cases additional dimens files can be created like sw360. If screen is less than 360 dp width,it will use the values from default dimens file, if 360dp <= screen size < 480dp then sw360 will be used. The same simple logic works for each created sw dimens file.
Upvotes: 2
Reputation: 156
In android you are dealing with dp/sp values. Don't think of physical size. There's this nifty plugin that lets you convert your sp/dp values to different buckets. You can add https://plugins.jetbrains.com/plugin/9349-dimenify
Upvotes: 1
Reputation: 2496
Create multiple dimens.xml for your project, it will give size according to the display size
You Have to create multiple values folder and have to create dimens.xml inside them. A reference for those folders are:
values-sw720dp 10.1” tablet 1280x800 mdpi
values-sw600dp 7.0” tablet 1024x600 mdpi
values-sw480dp 5.4” 480x854 mdpi
values-sw480dp 5.1” 480x800 mdpi
values-xxhdpi 5.5" 1080x1920 xxhdpi
values-xxxhdpi 5.5" 1440x2560 xxxhdpi
values-xhdpi 4.7” 1280x720 xhdpi
values-xhdpi 4.65” 720x1280 xhdpi
values-hdpi 4.0” 480x800 hdpi
values-hdpi 3.7” 480x854 hdpi
values-mdpi 3.2” 320x480 mdpi
values-ldpi 3.4” 240x432 ldpi
values-ldpi 3.3” 240x400 ldpi
values-ldpi 2.7” 240x320 ldpi
Upvotes: 1