Support various screen-size in the Android UI – AndroidPub

Read Time:1 Minute, 39 Second
Reference : [안드앱콘1] 다양한 스크린 사이즈에서의 UI 처리 http://www.androidpub.com/?mid=android_dev_info&category=127161& amp;page=4&document_srl=320322
Points
– Handle resource by folder names
  • res/layout/my_layout.xml: Normal screen-size layout
  • res/layout-small/my_layout.xml: Small screen-size layout
  • res/layout-large/my_layout.xml: Large screen-size layout
  • res/drawable-ldpi/my_icon.png: Icons for low density
  • res/drawable-mdpi/dpi/my_icon.png: Icons for medium density
  • res/drawable-hdpi/my_icon.png: Icons for high density
  • res/drawable-nodpi/composite.xml: Resources that unrelated with density
– Do we need to generate different resources for all devices?
  • DIP: Density Independent Pixel: Ensure compatibilities for different devices
  • QVGA – 320dip.426dip
  • HVGA – 320dip,480dip
  • WVGA854 – 320dip,569dip
  • Suggestion: Design layout using only DIP in HVGA normal screen.
  • Easy to understand due to equal (1:1) px and dip
– Use “RelativeLayout”

– Resource folders for bitmap resolution
  • drawable: xml drawable files which unrelate with resolution
  • drawable-ldpi: image files for low density, automatically adjust bimap size, can be the bimap cloudy sometimes.
  • drawable-mdpi: image files for medium density
  • drawable-hdpi: image files for high density
– Tip 2: Make bitmap based on HDPI
  • It is good practice for auto-size adjustment.
– Pre-Scaling
  • Scale the size during loading time.
  • Advantages for CPU
  • Example: If the 100×100 icon in “res/drawable-mdpi/” is loaded in the “High Density” screen, Android stretches the icon’s size to 150×150.
– Auto-Scaling
  • Scale the size during drawing.
  • Advantages for Memory
  • Automatically scale the size based on each density when bitmap is drawing in Canvas.
– Apply Bitmap
  • Bitmap resources are applying to each screen judiciously.
  • If you want to make a bitmap, then create HDPI density image.
  • If memory is low, then consider auto-scaling. If CPU is low, then consider pre-scaling.
– AndroidManifest.xml
<supports-screens
android:largeScreens=”true”
android:normalScreens=”true”
android:smallScreens=”true”
android:resizable=”true”
android:anyDensity=”true” />
</manifest>

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.