Android margin的负值的使用
来源:互联网 发布:微观调查数据 编辑:程序博客网 时间:2024/06/05 05:06
控件的margin属性是用来控制控件之间的间距,那么当两个控件需要重叠时该如何进行布局呢?
最常用的做法是使用FrameLayout帧布局,但是帧布局不能像LinearLayout能设置比重layout_weight灵活。
如果要使用LinearLayout布局的灵活性,又要使控件进行重叠,这时就可以使用margin的负值来进行处理重叠。
例子:
布局:
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical"
- tools:context=".MainActivity" >
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginLeft="10dp"
- android:layout_marginRight="10dp"
- android:layout_marginTop="10dp"
- android:orientation="horizontal" >
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginRight="-4dp"
- android:layout_weight="1"
- android:background="@drawable/register_bar_left_green"
- android:gravity="center"
- android:text="验证手机号码"
- android:textSize="12sp" />
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginLeft="-4dp"
- android:layout_marginRight="-4dp"
- android:layout_weight="1.1"
- android:background="@drawable/register_bar_mid_green"
- android:gravity="center"
- android:text="设置密码"
- android:textSize="12sp" />
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginLeft="-4dp"
- android:layout_marginRight="-4dp"
- android:layout_weight="1.1"
- android:background="@drawable/register_bar_mid_green"
- android:gravity="center"
- android:text="填写信息"
- android:textSize="12sp" />
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginLeft="-4dp"
- android:layout_weight="1.2"
- android:background="@drawable/register_bar_right_green"
- android:gravity="center"
- android:text="完成"
- android:textSize="12sp" />
- </LinearLayout>
- </LinearLayout>
0 0
- margin负值的使用
- Android margin的负值的使用
- Android margin的负值的使用
- margin负值的布局使用
- margin-right负值的使用
- 实用的margin负值
- margin的负值
- margin负值的妙用
- html-margin负值的运用
- 怎么理解负值的margin
- CSS margin负值的使用以及可能碰到的问题
- 前端开发:微吧里的各种margin负值
- margin属性的正负值确定
- margin为负值产生的影响
- css的负边距(margin负值)的绝招
- margin负值引起的层级(z-index)问题
- 解决ie6下margin-top为负值的bug
- IE6下为元素的margin设置负值不起作用
- 【回调函数】透彻理解
- 遍历数组的同时删除
- 移动场景下的图像处理应用设计
- log4php不能写文件
- 1019. General Palindromic Number (20)
- Android margin的负值的使用
- Git的常规设置(服务器的搭建)
- Inno Setup 5.0打包时无法包括隐藏文件
- Subsets
- 简单Map实用
- http://write.blog.csdn.net/postlist
- NAT与NAT穿透(一)
- magento 时区,对Magento的时间/时区的几点见解
- 快速排序(转载自脚本之家)