android多屏幕分辨率適配
做android開發,開源嘛,滿市場都是淩亂的機型,總少不了適配這樣或那樣的型號。在這裏分享一下自己在開發中用到的方法。首先要介紹一下drawable-mdpi、drawable-hdpi-1280x800、drawable-hdpi。這個相信好好看一下也明白。就是代表著分辨率 320X480、1280X800、480X800三款屏幕圖片資源包。其實適配也很多。我大致說一種就行,其他大家慢慢琢磨,或上網周轉。
說明一下這個圖的意思,就是我要說的配置方法,就是一套圖片資源(資源文件要看美工的設計了。最好能是XXX.9.png)配一套布局文件及多套數值文件。
布局文件:
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="https://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>
- <?xml version="1.0" encoding="utf-8"?>
- <resources>
- <!-- values-hdpi 480X800 -->
- <dimen name="imagewidth">320dip</dimen>
- </resources>
- <resources>
- <!-- values-hdpi-1280x800 -->
- <dimen name="imagewidth">320dip</dimen>
- </resources>
- <?xml version="1.0" encoding="utf-8"?>
- <resources>
- <!-- values-hdpi 480X320 -->
- <dimen name="imagewidth">320dip</dimen>
- </resources>
最後更新:2017-04-03 12:55:04