Android获取父组件大小,怎么让RelativeLayout 中的子控件只有RelativeLayout这个父控件的一半大小...

当前位置:我的异常网» Android » 怎么让RelativeLayout 中的子控件只有RelativeLayou

怎么让RelativeLayout 中的子控件只有RelativeLayout这个父控件的一半大小

www.myexceptions.net  网友分享于:2014-06-26  浏览:34次

如何让RelativeLayout 中的子控件只有RelativeLayout这个父控件的一半大小?

如何让RelativeLayout 中的子控件只有RelativeLayout这个父控件的一半大小?

我的XML代码里面,想让LinearLayout这个控件的大小有RelativeLayout的一半大小。

但是RelativeLayout没有类似layout_weight这样的效果,So,我做出来的布局效果就达不到我想要的那样。

我在解决想法是:在Java代码里面,获取RelativeLayout的真实宽度以及高度,然后,再设置LinearLayout的宽度与高度有RelativeLayout的一半大小。。

我想问的是:有没有直接在xml里面就能解决的方案?

下面是我写的xml布局代码:

android:id="@+id/parentLayout"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical"

android:weightSum="1" >

xmlns:android="http://schemas.android.com/apk/res/android"

android:id="@+id/mapView"

android:layout_width="match_parent"

android:layout_height="match_parent" >

android:id="@+id/search_dialog"

android:layout_width="wrap_content"

android:layout_height="match_parent"

android:background="#FFFFFF"

android:orientation="vertical"

android:layout_alignParentRight="true"

android:weightSum="1">

android:layout_width="match_parent"

android:layout_height="0dip"

android:layout_weight="0.15"

android:orientation="horizontal"

android:weightSum="1">

android:layout_width="0dip"

android:layout_height="match_parent"

android:layout_weight="0.3"

android:text="我的位置"/>

android:layout_width="0dip"

android:layout_height="match_parent"

android:layout_weight="0.7"

文章评论

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值