Fit layout only for Nexus 10 device

142 Views Asked by At

I have a xml layout file where i am giving margin-top for a text value.

For all the device it is android:layout_marginTop="25dp". But its not coming proporly in Nexus 10 device.I want to increase the margin only for Nexus 10 device. How can i achieve this.Can anyone please help me with this.

2

There are 2 best solutions below

0
Fenil Patel On

Please try the my solution, it's definitely fix your issue.

You have to create different dimens files inside the values folder for different screens. Like,

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

enter image description here

For more information you may visit here

Different values folders in android

http://android-developers.blogspot.in/2011/07/new-tools-for-managing-screen-sizes.html

You can make use of Android Studio plugin called Dimenify to auto generate dimension values for other pixel buckets based on custom scale factors. Its still in beta, be sure to notify any issues/suggestions you come across to the developer.

0
Umair On

According to documentation you should create separate asset folders for your requirement and then place the layout file in it:

Just for giving you the idea this is the normal practice.

res/layout-sw600dp/main_activity.xml   # For 7” tablets (600dp wide and bigger)
res/layout-sw720dp/main_activity.xml   # For 10” tablets (720dp wide and bigger)

Also take a look at Official Document for more help.

And this question will also give you the idea : Layout for tablets in Android