当前位置:我的异常网» 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"
文章评论