閱讀381 返回首頁    go 阿裏雲 go 技術社區[雲棲]


android的適配方法

首先要介紹一下drawable-mdpi、drawable-hdpi-1280x800、drawable-hdpi。這個相信好好看一下也明白。就是代表著分辨率 320X480、1280X800、480X800三款屏幕圖片資源包。其實適配也很多。我大致說一種就行,其他大家慢慢琢磨,或上網周轉。



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


布局文件:


  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="https://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>  
數值文件:
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <resources>  
  3.     <!-- values-hdpi 480X800 -->  
  4.     <dimen name="imagewidth">320dip</dimen>      
  5. </resources>  

  1. <resources>  
  2.     <!-- values-hdpi-1280x800 -->  
  3.     <dimen name="imagewidth">320dip</dimen>      
  4. </resources>  

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <resources>  
  3.     <!-- values-hdpi  480X320 -->  
  4.     <dimen name="imagewidth">320dip</dimen>      
  5. </resources> 

最後更新:2017-04-03 08:26:18

  上一篇:go 保險成電商角逐互聯網金融利器
  下一篇:go 朋友圈營銷魚龍混雜 微信商業化謹慎前行