我正在使用MPAndroidChart庫創建餅圖。在我的應用程序中,我有一個黑色背景,餅圖描述的文本顏色是灰色的,默認情況下不適合我。我無法改變它。如何更改MPAndroidChart中餅圖描述的文本顏色?
如何更改說明的文字顏色?
我的餅圖:
我正在使用MPAndroidChart庫創建餅圖。在我的應用程序中,我有一個黑色背景,餅圖描述的文本顏色是灰色的,默認情況下不適合我。我無法改變它。如何更改MPAndroidChart中餅圖描述的文本顏色?
如何更改說明的文字顏色?
我的餅圖:
使用setDescriptionColor(int color)
方法
chart.setDescriptionColor(getResources().getColor(R.color.your_color));
Hope this Helpful text color also you can change from here.
Into your Library **"MPChartLib"**
First Go:- Package:- Chart---> Chart.java
Then Go:- init();
Change Pie Chart Discription text color:-
public void setDescriptionColor(int color) {
mDescPaint.setColor(color);
}
Change other texts Color From here:-
mDescPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mDescPaint.setColor(Color.BLACK);
mDescPaint.setTextAlign(Align.RIGHT);
mDescPaint.setTextSize(Utils.convertDpToPixel(9f));
mInfoPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mInfoPaint.setColor(Color.rgb(0, 0, 0)); // black
mInfoPaint.setTextAlign(Align.CENTER);
mInfoPaint.setTextSize(Utils.convertDpToPixel(15f));
mDrawPaint = new Paint(Paint.DITHER_FLAG);
現在,事情我有點改變。所以,我知道最新的解決辦法是:
description.setTextColor(ContextCompat.getColor(context, R.color.your_color));
其中description
立場Description description = new Description();
請不要重複你的問題,只是編輯現有的問題,它會撞到隊列上方。 –
哇...我不知道這....感謝傑伊這個新的提示:) – Bharat