Android - detect small tablet vs big phone?

后端 未结 2 1319
耶瑟儿~
耶瑟儿~ 2020-12-19 11:20

The app I\'m developing contains 2 separate layouts: one is for the regular phones, other for small tablets such as NOOKcolor. The decision which is which is made based on t

2条回答
  •  一个人的身影
    2020-12-19 12:15

    Check out the documentation for Supporting Multiple Screens. You can follow a predetermined folder naming structure so that Android will load different layouts and drawables for different screen sizes/densities.

    For example:

    res/layout/my_layout.xml             // layout for normal screen size ("default")
    res/layout-small/my_layout.xml       // layout for small screen size
    res/layout-large/my_layout.xml       // layout for large screen size
    res/layout-xlarge/my_layout.xml      // layout for extra large screen size
    res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
    
    res/drawable-mdpi/my_icon.png        // bitmap for medium density
    res/drawable-hdpi/my_icon.png        // bitmap for high density
    res/drawable-xhdpi/my_icon.png       // bitmap for extra high density
    

提交回复
热议问题