现在,市场上android的机型太多,如何让自己的应用更多的适配不同的机型,这是一个非常现实的并且是要处理解决的问题。android官方给出的解决文档是从三个方向来分析处理的。
(1)支持不同屏幕大小的设备(Supporting Different Screen Sizes)
1.1 合理使用wrap_content,match_parent
1.2 尽可能的使用 RelativeLayout
1.3 针对不同的机型,使用不同的布局文件(Use Size Qualifiers):
res/layout/main.xml
res/layout-large/main.xml
1.4 尽量使用点9图片(Use Nine-patch Bitmaps)
(2)支持不同屏幕密度的设备(Supporting Different Screen Densities)
2.1 使用与密度无关的相素单位(Use Density-independent Pixels)-----dp,sp
android:layout_height="wrap_content"
android:text="@string/clickme"
android:layout_marginTop="20dp" />
android:layout_height="wrap_content"
android:textSize="20sp" />
2.2 对不同的设备提供可选择的图片(Provide Alternative Bitmaps)
不同分辨率之间的比例关系:
xhdp