如何使用 MPAAndroid 在 Android 中设置图表大小
How to set Chart Size in Android Using MPAAndroid
我是 android 的新人。我已经使用这个 Link 创建了条形图。但是当我 运行 我的 Emulator 。它给出了非常小尺寸的图表。
main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainLayout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
</RelativeLayout>
错误快照:Link
提前感谢您的帮助
您正在使用相对布局来存储您的图表吗?您可以尝试将主容器的参数设置为 fill_parent
,并将图表的参数设置为固定或 fill_parent
我为此使用了 FrameLayout,但这个具有类似参数的 RelativeLayout 也能正常工作。
这对我有用:
<FrameLayout
android:id="@+id/fl"
android:layout_width="fill_parent"
android:layout_height="210dp">
<com.github.mikephil.charting.charts.BarChart
android:id="@+id/cl"
android:layout_width="0dp"
android:layout_height="200dp" />
</FrameLayout>
在此示例中,图表的高度是固定的,宽度是屏幕的宽度。
首先感谢@Virthuss 的帮助。我在 activity class ;
上创建了一个框架布局
private FrameLayout mainLayout;
mainLayout = (FrameLayout) findViewById(R.id.mainLayout);
和 XML 一侧。称为
之类的框架布局
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainLayout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
再次感谢您的帮助。
我是 android 的新人。我已经使用这个 Link 创建了条形图。但是当我 运行 我的 Emulator 。它给出了非常小尺寸的图表。
main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainLayout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
</RelativeLayout>
错误快照:Link 提前感谢您的帮助
您正在使用相对布局来存储您的图表吗?您可以尝试将主容器的参数设置为 fill_parent
,并将图表的参数设置为固定或 fill_parent
我为此使用了 FrameLayout,但这个具有类似参数的 RelativeLayout 也能正常工作。
这对我有用:
<FrameLayout
android:id="@+id/fl"
android:layout_width="fill_parent"
android:layout_height="210dp">
<com.github.mikephil.charting.charts.BarChart
android:id="@+id/cl"
android:layout_width="0dp"
android:layout_height="200dp" />
</FrameLayout>
在此示例中,图表的高度是固定的,宽度是屏幕的宽度。
首先感谢@Virthuss 的帮助。我在 activity class ;
上创建了一个框架布局private FrameLayout mainLayout;
mainLayout = (FrameLayout) findViewById(R.id.mainLayout);
和 XML 一侧。称为
之类的框架布局<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainLayout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
再次感谢您的帮助。