1
App 위젯의 ImageView에 캔버스로 그려진 비트 맵을 렌더링하려고합니다. 그 작업을 할 수 없다, 나는 RemoteViews 개체없이, 그래서 그냥 캔버스에 일부 사각형을 렌더링하려고 시도하지 않고 간단한 예제를 시도하고 ImageView에 설정합니다. 나는 빈 활동을 보았을 뿐이다. 나는 그런 스택 overlow과 다른 장소에서 검색 후 setDrawingCacheEnabled 방법을 시도하는 등 다양한 부분을 조정했습니다Canvas에서 ImageView로 ImageBitmap을 비트 맵으로 설정할 수 없습니다. 비트 맵
LinearLayout layout = new LinearLayout (this);
layout.setDrawingCacheEnabled(true);
try
{
Bitmap bitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
Paint red = new Paint();
red.setColor(0xCC0000);
Paint blue = new Paint();
blue.setColor (0x0099CC);
canvas.drawRect(0, 0, 100, 100, red);
int percent = 55;
canvas.drawRect(0, 0, percent, 100, blue);
ImageView imageView = new ImageView (this);
imageView.setDrawingCacheEnabled(true);
imageView.setImageBitmap(bitmap);
imageView.setAdjustViewBounds(true);
imageView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
layout.addView(imageView);
}
catch(Exception e)
{
Log.e("ElectionForecastWidgetProvider", "error with bar", e);
}
this.setContentView(layout);
: 다음 코드 샘플입니다. 누구나 통찰력을 제공 할 수 있습니까? 감사!
괜찮아요! 그게 문제 인 것 같아, 감사 하리스 티! – Bennidhamma