How to prepare layout,drawable folders for 7“,10” android tablets for both landscape and portrait?

后端 未结 4 2216
小鲜肉
小鲜肉 2020-12-24 04:35

I have prepared my drawables for 7\" tablets as (Nexus 7)

 drawable-large-hdpi-port
 layout-large-hdpi-port

I am getting errors while doing

相关标签:
4条回答
  • 2020-12-24 04:54

    try below :-

    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-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
    

    also see below :-

    enter image description here

    0 讨论(0)
  • 2020-12-24 04:57

    Use this:

    Wrong: drawable-hdpi-port/
    Correct: drawable-port-hdpi/
    

    You can see this link

    0 讨论(0)
  • 2020-12-24 05:00

    The recommended way is to use layout-swxxdp qualifier. If you need to differentiate landscape/portrait

    res/layout-sw600dp/   # For 7” tablets (600dp wide and bigger)
    res/layout-sw720dp/   # For 10” tablets (720dp wide and bigger)
    res/layout-sw600dp-port/   # For 7” tablets in portrait (600dp wide or bigger)
    res/layout-sw720dp-port/  # For 10” tablets in portrait (720dp wide or bigger)
    
    0 讨论(0)
  • 2020-12-24 05:18

    You are naming the folders in the wrong way. In Android, there is a rule or order in which you name your resource folders. You should provide your qualifier names in that order.

    Check this documentation table on providing resources. Your should name your folders in the order provided in the table.(Its better if you read the whole page, because it'll give you a better understanding in providing resources)

    Here you should name the folders as

    layout-large-port-hdpi
    drawable-large-port-hdpi
    

    For preparing the resource folders for tablets, you can use either the screen size attribute or shortest width attribute.

    For e.g

    If you use screen size attribute, you can name folders like

    layout-large-... (for 7" devices)
    layout-xlarge-... (for 10" devices)
    

    I you use shortest width attribute, you can use

    layout-sw600dp-... (for 7" devices)
    layout-sw720dp-... (for 10" devices)
    

    Remember shortest width attribute works only on devices from 3.2 (API 13).

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