轉:android 屏幕適配小結

作android開發,開源嘛,滿市場都是凌亂的機型,總少不了適配這樣或那樣的型號。在這裏分享一下本身在開發中用到的方法。html

首先要介紹一下drawable-mdpi、drawable-hdpi-1280x800、drawable-hdpi。這個相信好好看一下也明白。就是表明着分辨率 320X480、1280X800、480X800三款屏幕圖片資源包。其實適配也不少。我大體說一種就行,其餘你們慢慢琢磨,或上網週轉。android

 

說明一下這個圖的意思,就是我要說的配置方法,就是一套圖片資源(資源文件要看美工的設計了。最好能是XXX.9.png)配一套佈局文件及多套數值文件。web

佈局文件:app

 

 

[html]   view plain copy print ?
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:layout_width="fill_parent"  
  4.     android:layout_height="fill_parent"  
  5.     android:orientation="vertical" >  
  6.   
  7.     <ImageView  
  8.         android:layout_width="@dimen/imagewidth"  
  9.         android:layout_height="wrap_content"  
  10.         android:background="@drawable/ic_launcher" />  
  11.   
  12. </LinearLayout>  

數值文件:oop

 

 

[html]   view plain copy print ?
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <resources>  
  3.     <!-- values-hdpi 480X800 -->  
  4.     <dimen name="imagewidth">320dip</dimen>      
  5. </resources>  

 

[html]   view plain copy print ?
  1. <resources>  
  2.     <!-- values-hdpi-1280x800 -->  
  3.     <dimen name="imagewidth">320dip</dimen>      
  4. </resources>  

 

[html]   view plain copy print ?
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <resources>  
  3.     <!-- values-hdpi  480X320 -->  
  4.     <dimen name="imagewidth">320dip</dimen>      
  5. </resources>
相關文章
相關標籤/搜索