Layout folders for Google Nexus 7 and 10

后端 未结 6 1180
逝去的感伤
逝去的感伤 2020-12-13 10:45

I am developing an application for google nexus 7 and 10. But there is a problem. I don\'t know which layout folder should be used for 7 and 10.

相关标签:
6条回答
  • 2020-12-13 11:09

    According to http://android-developers.blogspot.com/2012/07/getting-your-app-ready-for-jelly-bean.html

    Nexus 7 (2012) should be tvdpi

    Then, in my opinion

    For Nexus 7 (2012)

    • Layout file in layout-sw600dp-land, layout-sw600dp-port

    • Image resources in drawable-sw600dp-tvdpi

    For Nexus 10

    • Layout file in layout-sw720dp-land, layout-sw720dp-port

    • Image resources in drawable-sw720dp-xhdpi (1600x2560)

    0 讨论(0)
  • 2020-12-13 11:12

    Since android 3.2 you should use layout-sw600dp for the 7" tablet and layout-720dp for the 10". If you want to keep backwards compatibility with older version of android (pre 3.2, you should also use the old layout-xlarge* notation

    0 讨论(0)
  • 2020-12-13 11:22

    For nexus 10 you can put your layout in layout-sw720dp-land-xhdpi folder.

    0 讨论(0)
  • 2020-12-13 11:28

    You can now use the Google Design "device metrics" website. It has a lot of devices listed.

    Link: https://design.google.com/devices/

    0 讨论(0)
  • 2020-12-13 11:32

    For nexus 7

    layout-large-hdpi
    

    For nexus 10

    layout-xlarge-xhdpi
    

    Note: The app takes images from these folders only if you have not given higher precedence qualifiers. For example if you have given a layout folder like layout-sw360dp the app will take only the images from this folder even if you have given separate layouts like the one I said above. Because in android there is an order of precedence in which you have to give layouts.

    Check this official doc for the order of precedence of qualifiers.

    EDIT: Providing layouts for Tablets is a very confusing thing in Android. I had a horrible time in providing layouts for tablets. However I finally succeeded after so many attempts. Having said that one thing you have to remember is that, even if you have not given the right folder, Android will take the next suitable layout folder with respect to the device.

    Now regarding your comment, for samsung 7, I think the ideal layout will be

    layout-large-mdpi.
    

    And for samsung 7.7, it may be

    layout-large-hdpi (which I haven't tried yet)
    

    And for Samsung 10.1, it will be

    layout-xlarge-mdpi
    

    Regarding your Nexus 10, you have to make separate images to fit to its size.

    0 讨论(0)
  • 2020-12-13 11:32

    To add to @blackbelt, I was testing on my Nexus 7 and on a 600x1024mdpi emulator and found that the two will be considerably off.

    The quick way to fix this would be to create the layout folders:

    layout-sw600dp-land-tvdpi

    layout-sw600dp-port-tvdpi

    This has been tested and verified to work for the Nexus 7 specifically since the tvdpi density is rare.

    So the layout folders:

    layout-sw600dp-land

    layout-sw600dp-port

    would then be for devices with a mdpi density. There are way more devices that fall into the second category, so you really shouldn't rely on using the naming convention without tvdpi to support the Nexus 7.

    This obviously can apply to the Galaxy Note and other devices that are hdpi and so on.

    0 讨论(0)
提交回复
热议问题