android – 将RelativeLayout分成两半

嗨我创建了一个包含2个按钮,一个单选按钮和一个图表视图的RelativeLayout.

我想现在在图表中显示两个不同的数据.

如何将RelativeLayout分成两半?

这是我目前的XML代码

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <Button
        android:id="@+id/BtnStart"
        android:layout_width="100dip"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_marginTop="5dip"
        android:text="SlaveEnable" />

    <Button
        android:id="@+id/BtnStop"
        android:layout_width="100dip"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_marginTop="5dip"
        android:layout_toRightOf="@id/BtnStart"
        android:text="Slavedisable" />

    <RadioButton
        android:id="@+id/BtnSaveFile"
        android:layout_width="100dip"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_toRightOf="@id/BtnStop"
        android:text="SaveFile" />

    <helog.diwesh.NugaBest.GraphView
        android:id="@+id/gview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@id/BtnStart"
        android:layout_alignParentRight="true" />

</RelativeLayout>

解决方法

试试这个布局.如果不完美,这应该适用于一些变化.这将添加两个图表.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <Button
        android:id="@+id/BtnStart"
        android:layout_width="100dip"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_marginTop="5dip"
        android:text="SlaveEnable" />

    <Button
        android:id="@+id/BtnStop"
        android:layout_width="100dip"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_marginTop="5dip"
        android:layout_toRightOf="@id/BtnStart"
        android:text="Slavedisable" />

    <RadioButton
        android:id="@+id/BtnSaveFile"
        android:layout_width="100dip"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_toRightOf="@id/BtnStop"
        android:text="SaveFile" />

<LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="match_parent"
            android:layout_above="@id/BtnStart"
            android:layout_alignParentRight="true"
        android:orientation="vertical" 
    android:weightSum="2" >

    <helog.diwesh.NugaBest.GraphView
                android:id="@+id/gview1"
                android:layout_height="0dp"
                android:layout_width="match_parent"
        android:layout_weight="1" />

    <helog.diwesh.NugaBest.GraphView
                android:id="@+id/gview2"
                android:layout_height="0dp"
                android:layout_width="match_parent"
        android:layout_weight="1" />

</LinearLayout>

</RelativeLayout>

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...