MPAndroidChart Line Chart problems

android mpandroidchart

659 просмотра

1 ответ

I'm trying to show several line charts but the scrolling is not working for the page where the charts should be shown. I use a viewpager which is inside of a Coordinator Layout.

I'd like to achieve too the following things:

  • Quit curve's line
  • Quit the colors labels from the Legend

I know that Coordinator Layout and Viewpager sometimes need some tricky workaround, but until this moment I couldn't find the solution. I need to add more charts...

resume charts

charts stop scrolling

The main xml:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<android.support.design.widget.AppBarLayout
    android:id="@+id/app_bar_layout"
    android:layout_width="match_parent"
    android:layout_height="112dp"
    android:background="@color/colorPrimary"
    android:elevation="@dimen/elevation_toolbar"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    android:fitsSystemWindows="true">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:contentScrim="@color/colorPrimary"
        app:expandedTitleMarginEnd="64dp"
        app:expandedTitleMarginStart="48dp"
        app:layout_scrollFlags="scroll|enterAlways"
        android:fitsSystemWindows="true">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?actionBarSize"
            android:layout_marginLeft="@dimen/list_toolbar_side_margin"
            android:layout_marginRight="@dimen/list_toolbar_side_margin"
            app:layout_collapseMode="pin" />

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            style="@style/AppTabLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            app:tabGravity="fill"
            app:tabMode="fixed"
            app:tabTextAppearance="@style/AppTabTextAppearance"/>

    </android.support.design.widget.CollapsingToolbarLayout>

</android.support.design.widget.AppBarLayout>

<ProgressBar
    android:id="@+id/progress_bar_garden"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:visibility="gone"/>

<android.support.v4.view.ViewPager
    android:id="@+id/viewpager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    />

And the charts fragment xml:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <ProgressBar
        android:id="@+id/progress_bar_charts"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:visibility="gone" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <com.github.mikephil.charting.charts.LineChart
            android:id="@+id/temp_chart"
            android:layout_width="@dimen/show_plant_chart_width"
            android:layout_height="@dimen/show_plant_chart_height"
            android:layout_marginStart="@dimen/show_plant_chart_margin_start" />

        <com.github.mikephil.charting.charts.LineChart
            android:id="@+id/humidity_chart"
            android:layout_width="@dimen/show_plant_chart_width"
            android:layout_height="@dimen/show_plant_chart_height"
            android:layout_marginStart="@dimen/show_plant_chart_margin_start"
            android:layout_marginTop="@dimen/show_plant_chart_margin_top" />

    </LinearLayout>

</RelativeLayout>

Автор: Ignacio Giagante Источник Размещён: 08.11.2019 11:24

Ответы (1)


1 плюс

I resolved this issue using a recycleView. It appears that MPAndroidChart Line Chart has a problem with ScrollView. I don't why.

Автор: Ignacio Giagante Размещён: 25.08.2016 12:03
Вопросы из категории :
32x32