我有一个 ViewPager ,它显示来自 url.but 的图像。但我想在 ViewPager 中的图像上绘制矩形。我不知道如何实现这一点。我试图在 PagerAdapter 中做到这一点。我在下面给出了尝试但没有给出任何结果
@Override
public Object instantiateItem(ViewGroup view, int position) {
View imageLayout = inflater.inflate(R.layout.pager_image, view, false);
final ImageView imageView = (ImageView) imageLayout.findViewById(R.id.image);
final ProgressBar spinner = (ProgressBar) imageLayout.findViewById(R.id.loading);
imageNameDisplay.setText(imageNames.get(position));
Bitmap bitmap = Bitmap.createBitmap((int) getWindowManager()
.getDefaultDisplay().getWidth(), (int) getWindowManager()
.getDefaultDisplay().getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
imageView.setImageBitmap(bitmap);
Paint paint = new Paint();
paint.setColor(Color.RED);
paint.setStyle(Paint.Style.FILL_AND_STROKE);
paint.setStrokeWidth(110);
float leftx = 20;
float topy = 20;
float rightx = 50;
float bottomy = 50;
canvas.drawRect(leftx, topy, rightx, bottomy, paint);
........
.........
}
请指导我..