一、首先添加远程依赖或者本地依赖MPAndroidChart的jar包),没有包的可联系我发你。
二、new一个 Empty Activity,名称取你喜欢的,我的示例中是叫“f_ym4”, xml页面代码如下
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.github.mikephil.charting.charts.BarChart
android:id="@+id/bc"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
三、编辑对应页面class的代码,源码来源于CSDN,但不全,我把完整能用的代码附上
package com.example.daohang;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.util.DisplayMetrics;
import