0
点赞
收藏
分享

微信扫一扫

android多屏幕分辨率适配

皮皮球场 2022-11-29 阅读 163


首先要介绍一下drawable-mdpi、drawable-hdpi-1280x800、drawable-hdpi。这个相信好好看一下也明白。就是代表着分辨率 320X480、1280X800、480X800三款屏幕图片资源包。其实适配也很多。我大致说一种就行,其他大家慢慢琢磨,或上网周转。

android多屏幕分辨率适配_android


说明一下这个图的意思,就是我要说的配置方法,就是一套图片资源(资源文件要看美工的设计了。最好能是XXX.9.png)配一套布局文件及多套数值文件。

android多屏幕分辨率适配_html_02

布局文件:



[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>

数值文件:

[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> 
举报

相关推荐

0 条评论