android自适应屏幕
来源:互联网 发布:道光知乎 编辑:程序博客网 时间:2024/06/07 06:18
android xml的布局要自适应各种屏幕的话,需要使用opx布局,在app/res/values/styles.xml中增加如下的代码
<!-- 全屏幕拉伸--> <style name="layout_full"> <item name="android:layout_width">fill_parent</item> <item name="android:layout_height">fill_parent</item> </style> <!-- 固定自身大小--> <style name="layout_wrap"> <item name="android:layout_width">wrap_content</item> <item name="android:layout_height">wrap_content</item> </style> <!-- 横向分布--> <style name="layout_horizontal" parent="layout_full"> <item name="android:layout_width">0px</item> </style> <!-- 纵向分布--> <style name="layout_vertical" parent="layout_full"> <item name="android:layout_height">0px</item> </style>并在main.xml中增加如下的代码
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" style="@style/layout_full" android:orientation="vertical"> <LinearLayout style="@style/layout_vertical" android:layout_weight="1" android:orientation="horizontal"> <View style="@style/layout_horizontal" android:background="#aa0000" android:layout_weight="1"/> <View style="@style/layout_horizontal" android:background="#00aa00" android:layout_weight="4"/> <View style="@style/layout_horizontal" android:background="#0000aa" android:layout_weight="3"/> <View style="@style/layout_horizontal" android:background="#aaaaaa" android:layout_weight="2"/> </LinearLayout> <LinearLayout style="@style/layout_vertical" android:layout_weight="2" android:orientation="vertical"> <View style="@style/layout_vertical" android:background="#ffffff" android:layout_weight="4"/> <View style="@style/layout_vertical" android:background="#aa0000" android:layout_weight="3"/> <View style="@style/layout_vertical" android:background="#00aa00" android:layout_weight="2"/> <View style="@style/layout_vertical" android:background="#0000aa" android:layout_weight="1"/> </LinearLayout></LinearLayout>通过opx和weight来成比例地显示内容
【1】 4中必须知道的android屏幕自适应解决方案
0 0
- android 屏幕自适应问题
- android:屏幕自适应问题
- android屏幕自适应研究
- [Android]屏幕自适应布局
- android 屏幕自适应
- android屏幕自适应研究
- android:屏幕自适应
- android屏幕自适应
- android 自适应屏幕
- android屏幕自适应
- android:屏幕自适应
- android:屏幕自适应
- android:屏幕自适应
- android:屏幕自适应
- android:屏幕自适应
- android 自适应屏幕
- android:屏幕自适应
- android 自适应屏幕
- 递推递归练习--M(数值分解)
- Twitter Lite以及大规模的高性能React渐进式网络应用
- LintCode 29 交叉字符串
- 【error】VS2010 LINK1123: failure during conversion to COFF: file invalid or corrupt
- 调停者模式(Mediator Pattern,对象行为型模式,中介者模式)
- android自适应屏幕
- 浙大校赛 ZOJ 3956Course Selection System (01背包)
- nginx架构(三)Nginx服务器的代理服务
- 递推递归练习M
- 24段魔尺--小海龟图案
- 动态规划练习一 24:鸣人的影分身
- 10023---linux查看及修改文件权限以及相关
- The first girlfriend -- AngularJS
- 13:最大上升子序列和