RelativeLayout 如何实现平分布局空间
来源:互联网 发布:数据多用list还是map 编辑:程序博客网 时间:2024/04/29 22:58
平分布局在LinearLayout中很简单,就是设置 layout_weight
但是我们有时候不得不在RelativeLayout 中实现平分布局空间,所以怎么做呢? 很简单
代码
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <View android:id="@+id/strut" android:layout_width="0dp" android:layout_height="0dp" android:layout_centerVertical="true"/> <ImageView android:id="@+id/img1" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignBottom="@+id/strut" android:layout_alignParentTop="true" android:src="@drawable/img_artilce"/> <ImageView android:id="@+id/img2" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignTop="@+id/strut" android:layout_alignParentBottom="true" android:src="@drawable/img_artilce"/></RelativeLayout>
是不是很简单?相信大家一看就能明白。
那水平平分呢?其实是一样的,只是换一下方向而已
代码
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <View android:id="@+id/strut" android:layout_width="0dp" android:layout_height="0dp" android:layout_centerHorizontal="true"/> <ImageView android:id="@+id/img1" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignRight="@+id/strut" android:layout_alignParentLeft="true" android:src="@drawable/img_artilce"/> <ImageView android:id="@+id/img2" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignLeft="@+id/strut" android:layout_alignParentRight="true" android:src="@drawable/img_artilce"/></RelativeLayout>
好啦,就这样。有问题欢迎提出
1 0
- RelativeLayout 如何实现平分布局空间
- RelativeLayout布局下实现控件平分空间
- 【Android控件布局】Layout 水平平分空间、垂直平分空间
- 【Android控件布局】Layout 水平平分空间、垂直平分空间
- 【Android控件布局】Layout 水平平分空间、垂直平分空间
- Android RelativeLayout中实现控件平分屏幕
- Android RelativeLayout中实现控件平分屏幕
- RelativeLayout(Android)中实现控件平分屏幕
- Andriod之RelativeLayout 平分
- LinearLayout 实现左中右 平分屏幕宽度布局
- RelativeLayout实现百分比布局
- 代码实现 RelativeLayout布局
- relativelayout实现梅花布局
- 初学安卓平分空间排列相同内嵌布局
- RelativeLayout代码实现相对布局
- android-RelativeLayout实现水平布局
- 自定义RelativeLayout view实现布局。
- 动态实现RelativeLayout,LinearLayout布局
- smarty模板引擎_8-扩展块函数插件
- 【mahapps.metro】使用如何添加WPF窗体图标
- Oracle学习笔记(5)——查询
- jvm笔记
- 【错误1】环境变量path的值超过1023字符,无法设置改值
- RelativeLayout 如何实现平分布局空间
- Cocos 安装和配置和初探(创建自己的Scene
- 压力测试 硬件测试 IPTraf 命令行网络实时监控
- GeekBand--第四周分享
- wordpress搬家插件cnblogs2wp,实测好用
- 如何由方法论设计敏捷实践, 改变团队成员既有的思维, 行为模式?
- acl权限和设置方法
- 用树莓派 + Python + OpenCV 实现家庭监控和移动目标探测(下)
- 在ROS中传递图像消息(一)