【HELP】如何Android单套资源文件适应大部分屏幕分辨率 本帖最后由 oathevil 于 2013-07-26 17:15:33 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用 weight,来设定,按照比例分配 参考下吧,个人感觉layout_weight="1"等分的时候有用,其他时候就不太好控制了。另外textsize用px做单位文本大小也没法拉伸,用sp比较好。 <LinearLayout android:id="@+id/inputbar_others_container" android:layout_width="wrap_content" android:layout_height="wrap_content"> <Button android:id="@+id/swich_to_symbol" android:background="@drawable/inputbar_btton_bg" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:layout_alignParentBottom="true" android:clickable="true"/> <ImageButton android:id="@+id/inputbar_setting" android:background="@drawable/inputbar_btton_bg" android:src="@drawable/setting" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:layout_alignParentBottom="true" android:clickable="true"/> <ImageButton android:id="@+id/inputbar_tohand" android:background="@drawable/inputbar_btton_bg" android:src="@drawable/hand" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:layout_alignParentBottom="true" android:clickable="true"/> <ImageButton android:id="@+id/inputbar_speech" android:background="@drawable/inputbar_btton_bg" android:src="@drawable/mic" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:layout_alignParentBottom="true" android:clickable="true"/> <ImageButton android:id="@+id/inputbar_close" android:background="@drawable/inputbar_btton_bg" android:src="@drawable/to_hard_ime" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:layout_alignParentBottom="true" android:clickable="true"/> </LinearLayout> 最后发现了是AndroidMainfest.xml里面的<uses-sdk android:minSdkVersion="1" />在作怪,发现在值为1,2,3的时候都自适应, 但在8或者8以后的都会错位。(注:4、5、6、7没有尝试)查了下原因,大概是,随着Android版本的更新,有些界面的风格也开始变化。如果想保持早期低版本时的风格,那么minSdkVersion就应该被设置为相应的sdk版本。我想这差不多是较为合理的解释了,希望对初学者会有帮助。 布局中控件的位置不要用绝对坐标,尽量用相对位置来控制,图片用scaleType属性来控制,不考虑拉伸可以设置为fitXY 请教:QQ游戏大厅中游戏安装在内存卡的原理 Android FMRadio 自动搜台问题 SimpleCursorAdapter 是设计模式?名字叫什么? 使用MonkeyRunner不能运行press 如何查看android手机硬件基本信息 《2012Sundy高级课程更新》Android深入浅出系列课程文章列表 高分求实例化一个IBinder的接口 JNI如何调试?LOGE输出到哪了? Android群发短信的消息报告问题 android webview 开发 红米/三星Note分辨率错误 求推荐安卓教学视频 Android界面自适应分辨率的问题
另外textsize用px做单位文本大小也没法拉伸,用sp比较好。
<LinearLayout android:id="@+id/inputbar_others_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/swich_to_symbol"
android:background="@drawable/inputbar_btton_bg"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:layout_alignParentBottom="true"
android:clickable="true"/>
<ImageButton
android:id="@+id/inputbar_setting"
android:background="@drawable/inputbar_btton_bg"
android:src="@drawable/setting"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:layout_alignParentBottom="true"
android:clickable="true"/>
<ImageButton
android:id="@+id/inputbar_tohand"
android:background="@drawable/inputbar_btton_bg"
android:src="@drawable/hand"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:layout_alignParentBottom="true"
android:clickable="true"/>
<ImageButton
android:id="@+id/inputbar_speech"
android:background="@drawable/inputbar_btton_bg"
android:src="@drawable/mic"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:layout_alignParentBottom="true"
android:clickable="true"/>
<ImageButton
android:id="@+id/inputbar_close"
android:background="@drawable/inputbar_btton_bg"
android:src="@drawable/to_hard_ime"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:layout_alignParentBottom="true"
android:clickable="true"/>
</LinearLayout>
(注:4、5、6、7没有尝试)查了下原因,大概是,
随着Android版本的更新,有些界面的风格也开始变化。如果想保持早期低版本时的风格,那么minSdkVersion就应该被设置为相应的sdk版本。我想这差不多是较为合理的解释了,希望对初学者会有帮助。