1

I'm coding a little Android application for myself. And now I struggle with weights. If I use the code show down below my application shows nothing. But If I use for example 230dp it works perfectly. What I'm doing wrong with the weights. Can you help me out?

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/swipe_refresh_layout_history"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ScrollView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <LinearLayout
            android:layout_height="match_parent"
            android:layout_width="match_parent"
            android:orientation="vertical"
            android:id="@+id/linearLayoutHistory"
            android:weightSum="100">
            <com.github.mikephil.charting.charts.BarChart
                android:id="@+id/chart"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_marginTop="@dimen/activity_left_margin"
                android:layout_weight="50"/>

            <com.github.mikephil.charting.charts.BarChart
                android:id="@+id/weekdayChart"
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_marginTop="@dimen/activity_left_margin"
                android:layout_weight="50"/>
        </LinearLayout>

    </ScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
Peter234
  • 1,052
  • 7
  • 24
  • `0dp height`? with a size of 0 you shouldn't expect to show anything at all :) – saljuama Jan 01 '16 at 17:55
  • But that is what I read everywhere... e.g: http://stackoverflow.com/questions/6794141/androidlayout-height-50-of-the-screen-size – Peter234 Jan 01 '16 at 18:10

1 Answers1

0

I found out the answer myself. But I think I'm not the only one facing this problem, so I answer it here... It's a problem with scroll view and layout_weight. Just set the scrollview to: android:fillViewport="true" and it will work!

Hope I can help someone :)

Peter234
  • 1,052
  • 7
  • 24