作android開發,開源嘛,滿市場都是凌亂的機型,總少不了適配這樣或那樣的型號。在這裏分享一下本身在開發中用到的方法。html
首先要介紹一下drawable-mdpi、drawable-hdpi-1280x800、drawable-hdpi。這個相信好好看一下也明白。就是表明着分辨率 320X480、1280X800、480X800三款屏幕圖片資源包。其實適配也不少。我大體說一種就行,其餘你們慢慢琢磨,或上網週轉。android
![](http://static.javashuo.com/static/loading.gif)
說明一下這個圖的意思,就是我要說的配置方法,就是一套圖片資源(資源文件要看美工的設計了。最好能是XXX.9.png)配一套佈局文件及多套數值文件。web
![](http://static.javashuo.com/static/loading.gif)
佈局文件:app
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical" >
-
- <ImageView
- android:layout_width="@dimen/imagewidth"
- android:layout_height="wrap_content"
- android:background="@drawable/ic_launcher" />
-
- </LinearLayout>
數值文件:oop
- <?xml version="1.0" encoding="utf-8"?>
- <resources>
-
- <dimen name="imagewidth">320dip</dimen>
- </resources>
- <resources>
-
- <dimen name="imagewidth">320dip</dimen>
- </resources>
- <?xml version="1.0" encoding="utf-8"?>
- <resources>
-
- <dimen name="imagewidth">320dip</dimen>
- </resources>