How to make two androidplot, each one take 50% of the screen?

87 Views Asked by At

I'm trying to make two androidplot.xy.XYPlot each one takes 50% of the screen. I try to use android:weightSum. I put each androidplot.xy.XYPlot inside an LinearLayout, each take half the weight but the plot is not showing.

Here is my XML:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:weightSum="100"
    android:orientation="vertical" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="50"
            android:background="#FF003B"
            android:orientation="vertical" >
                <com.androidplot.xy.XYPlot
                    android:id="@+id/pawGraph"
                    style="@style/APDefacto.Light"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    app:rangeTitle="Pressure (cmH2O)"
                    app:graphMarginBottom="0dp" />
        </LinearLayout>
        
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="50"
            android:background="#FFE600"
            android:orientation="vertical" >
                <com.androidplot.xy.XYPlot
                    android:id="@+id/tidalVolume"
                    style="@style/APDefacto.Light"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    app:graphMarginBottom="0dp"
                    app:lineLabelTextSizeBottom="0dp"
                    app:rangeTitle="Tidal Volume" />
        </LinearLayout>
</LinearLayout>

The Android Studio Design View show the two layouts as I expected. Here is what Android Studio Design view looks like.

However, in my app both graphs does not show up.

If I set android:layout_height within com.androidplot.xy.XYPlot to something like 250dp. Then the graphs would show up. But now it is not 50% of the screen anymore.

What did I do wrong? How should I fix it?

1

There are 1 best solutions below

1
Divya Ghori On

Please XY Plot to width and height both are set match parent so show this plot 50% of the screen.