0
votes

I add a pie chart on my android application and it worked perfectly, but, despite the layout was defined to "match_parent", it got really small, I couldn't even read it.

I found a answer here on StackOverflow that says to put the chart as the content (setContentView(pieChart)) and it worked, but I want to add more elements below the chart so it can't be set as the content.

What should I do?

1
Can you post your layout XML? - dfinn
Actually, I already found a solution. I was using a LinearLayout as container for the chart. I changed it to <com.github.mikephil.charting.charts.PieChart> - Notheros
Hi @Notheros can you please tell me how you did that? I have the same issue, however I don't know how to use the PieChart specific layout as you mentioned. I mean, that is not a standard layout in the palette. Thank you! - user1060551

1 Answers

1
votes

Here is a layout I used which fixed my issue:

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

        <com.github.mikephil.charting.charts.PieChart
            android:id="@+id/piechart"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_marginTop="10dp"
            android:layout_weight="1">

        </com.github.mikephil.charting.charts.PieChart>


        ... other things ...


    </LinearLayout>