cardview中的MPAndroidChart饼图绘制得很小
我正在使用MPAndroidChart库在RecyclerView中绘制半饼图。 这是我的项目布局:cardview中的MPAndroidChart饼图绘制得很小,android,mpandroidchart,Android,Mpandroidchart,我正在使用MPAndroidChart库在RecyclerView中绘制半饼图。 这是我的项目布局: <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.and
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="3dp"
card_view:cardCornerRadius="12dp"
card_view:contentPadding="10dp"
android:layout_marginTop="8dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/platforms_title_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:drawablePadding="5dp"
android:fontFamily="@font/roboto"
android:gravity="center_vertical"
android:text="@string/platforms"
android:textAllCaps="true"
android:textColor="@color/colorTextStandard"
android:textSize="20sp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"/>
<TextView
android:id="@+id/platforms_count_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="8dp"
android:fontFamily="@font/roboto"
tools:text="4"
android:drawablePadding="5dp"
android:drawableStart="@drawable/ic_menu_monitor"
android:textColor="@color/colorTextStandard"
android:textSize="14sp"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"/>
<com.github.mikephil.charting.charts.PieChart
android:id="@+id/platforms_chart"
android:layout_width="match_parent"
android:layout_height="@dimen/platforms_card_height"
android:layout_below="@id/platforms_title_txt"/>
</RelativeLayout>
结果是piechart被画得很小,我无法控制它的大小
有什么想法或例子吗?我怎样才能得到固定大小的图表
谢谢。relativelayout.setLayoutParams(新建ViewGroup.LayoutParams( 恒定宽度, 恒定高度); (或) RelativeLayout布局=新的RelativeLayout(此)
RelativeLayout.LayoutParams LayoutParams=RelativeLayout.LayoutParams)layout.getLayoutParams()
layoutParams.height=dpToPx(您的高度)
layoutParams.width=dpToPx(您的宽度)
layout.setLayoutParams(layoutParams)
找到了问题
当我试图向下移动图表以减少占用的空间时,我给出的值太大了
我仍然需要给它一个固定的大小,不能使用match_parent,但我想我可以接受…你能添加屏幕截图吗?谢谢,但我试过了,但是PieChart还是太小或者看不见(卡片布局高度只包裹了textview)很抱歉这么晚才问…你的问题解决了吗?@Sharasys,谢谢,我在回复中写下了我的问题所在我为PieChart添加了一些最小高度谢谢,但我尝试了,但PieChart仍然太小或不可见(卡片布局高度仅包裹textview)
<com.github.mikephil.charting.charts.PieChart
android:id="@+id/platforms_chart"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/platforms_title_txt"/>