问题描述
我使用的是 MPAndroid 库中的 Linechart,但我的图表大小几乎没有问题。 我想在卡片视图中显示我的折线图,但我被迫为折线图宽度设置固定大小,因为“wrap-content”和“match-parent”似乎无法根据数据扩展图表宽度数字。 我不知道是我做错了什么,还是 MPAndroid 不允许我这样做,所以如果您有任何想法,请告诉我!谢谢
这是我的 xml 示例和显示它如何在我的应用程序中显示的屏幕截图:
<horizontalscrollview
android:id="@+id/graphScrollView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_margin="10dp"
android:fillViewport="false">
<com.google.android.material.card.MaterialCardView
android:layout_width="wrap_content"
android:layout_height="match_parent"
app:cardCornerRadius="10dp"
app:cardUseCompatPadding="true">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:foregroundGravity="center_horizontal">
<TextView
android:id="@+id/accountGraphTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginEnd="16dp"
android:gravity="end"
android:text="@string/account_chronology_score_title"
android:textColor="@color/medium_grey"
android:textSize="16sp"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="@id/graphLayout"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="@+id/graphLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.github.mikephil.charting.charts.LineChart
android:id="@+id/graphView"
android:layout_width="wrap_content"
android:layout_height="300dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/accountGraphTitle"
tools:layout_width="300dp" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
</horizontalscrollview>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)