We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
建议加入多种图标设置方法,目前 只能使用 drawable,在项目中,很多情况下都不会是使用本地drawable资源,更多的是使用其他的,例如我在做的项目,则是在网络动态加载图标
以下为一些修改参考: `
//设置图标 public void setDrawables(int[] drawables) { this.drawables = drawables; this.bitmaps = null; invalidate(); } //设置图标 public void setDrawables(Bitmap[] bitmaps) { setBitmaps(bitmaps); } //设置图标 public void setBitmaps(Bitmap[] bitmaps) { this.bitmaps = bitmaps; this.drawables = null; invalidate(); }
//drawMultiLinesTextAndIcon() // 绘制图标 if (drawableSize * drawableAvaiable != 0) { if (bitmap != null) { if (verticalValue == 1) { canvas.drawBitmap(bitmap, x + layout.getWidth(), y - drawableSize * drawableAvaiable / 2 - layout.getHeight() / 2 - descPadding, titlePaint); } else if (verticalValue == -1) { canvas.drawBitmap(bitmap, x + layout.getWidth(), y + descPadding + layout.getHeight() / 2 - drawableSize * drawableAvaiable / 2, titlePaint); } else { canvas.drawBitmap(bitmap, x + layout.getWidth(), y - drawableSize * drawableAvaiable / 2, titlePaint); } //btm.recycle(); } }
//回收资源 (若是传入bitmap 建议调用,请在Activity/Fragment 的适当时机调用,如:onDestroy() ) public void recycle() { if (bitmaps != null) { for (Bitmap bitmap : bitmaps) { bitmap.recycle(); } } }
使用:
// 先加载控件其他内容,过后再加载图标 if (NetUtil.isConn(mContext)) { Bitmap[] bitmaps = new Bitmap[url.length]; // 从url 加载图片,获取bitmap new Thread(() -> { for (int i = 0; i < bitmaps.length; i++) { bitmaps[i] = !TextUtils.isEmpty(url[i]) ? returnBitMap(url[i]) : null; } //更新视图 mHandler.post(() -> mRadarView.setDrawables(bitmaps)); }).start(); }
`
// Fragment 的onDetach() 释放资源. @Override public void onDetach() { super.onDetach(); if (mRadarView != null) mRadarView.recycle(); //释放bitmap }
XRadarView2.java.txt
The text was updated successfully, but these errors were encountered:
你可以fork此项目,然后在自己项目上修改提交Merge Request到此项目,这样看着比较麻烦~
Sorry, something went wrong.
@hust201010701 主要是,写项目写着写着想到了个问题,下次吧
No branches or pull requests
建议加入多种图标设置方法,目前 只能使用 drawable,在项目中,很多情况下都不会是使用本地drawable资源,更多的是使用其他的,例如我在做的项目,则是在网络动态加载图标
以下为一些修改参考:
`
使用:
`
XRadarView2.java.txt
The text was updated successfully, but these errors were encountered: