在RelativeLayout中平分两个控件

原文地址 http://blog.csdn.net/caroline_wendy/article/details/42704915


本文地址:http://blog.csdn.net/caroline_wendy


RelativeLayout在平分时,需要使用一个基准,就是在中间放置一个参考,一个在左面,一个在右面;
其中左右的宽度设置为android:layout_width=“0dp",根据内容自动填充;

如:
[html]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. <RelativeLayout  
  2.     xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:layout_width="match_parent"  
  4.     android:layout_height="match_parent"  
  5.     android:orientation="vertical">  
  6.   
  7.     <View  
  8.         android:id="@+id/eton_placeholder"  
  9.         android:layout_width="0dp"  
  10.         android:layout_height="0dp"  
  11.         android:layout_centerHorizontal="true"/>  
  12.   
  13.     <TextView  
  14.         android:id="@+id/eton_cardio_face_entry_text_view"  
  15.         android:layout_width="0dp"  
  16.         android:layout_height="wrap_content"  
  17.         android:layout_alignParentLeft="true"  
  18.         android:layout_below="@id/eton_chunyu_doctor_entry_text_view"  
  19.         android:layout_toLeftOf="@id/eton_placeholder"  
  20.         android:background="@color/pink"  
  21.         android:gravity="center"  
  22.         android:text="心率监测"  
  23.         android:textSize="36dp"/>  
  24.   
  25.     <TextView  
  26.         android:id="@+id/eton_pedometer_entry_text_view"  
  27.         android:layout_width="0dp"  
  28.         android:layout_height="wrap_content"  
  29.         android:layout_alignParentRight="true"  
  30.         android:layout_below="@id/eton_chunyu_doctor_entry_text_view"  
  31.         android:layout_toRightOf="@id/eton_placeholder"  
  32.         android:background="@color/orange"  
  33.         android:gravity="center"  
  34.         android:text="计步器"  
  35.         android:textSize="36dp"/>  
  36.   
  37. </RelativeLayout>  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值