0

我有一个图像视图。我需要在图像上显示各种文本。对于每个图像,文本的位置都不同。我将使用 x,y 的坐标给出位置值ImageView

任何猜测如何执行此操作?

4

3 回答 3

0

将图像和文本封装在布局中,然后为其父视图中的视图提供坐标,然后使用封装的视图组,如您的图像视图。

于 2012-11-21T11:22:11.993 回答
0
  1. 创建位图
  2. 创建画布
  3. 画出你需要的东西
  4. 将其发布到图像视图

像这样:

Bitmap drawingSurface = Bitmap.createBitmap(picBitmap.getWidth(), picBitmap.getHeight(), Bitmap.Config.ARGB_4444);

Canvas canvas = new Canvas(drawingSurface);
canvas.drawBitmap(picBitmap, 0, 0, null);

canvas.drawText("Hi!", 10, 10, new Paint());

myImageView.setImageBitmap(drawingSurface);
于 2012-11-21T11:22:34.283 回答
-1
Options options = new BitmapFactory.Options();
                    options.inScaled=false;
                    Bitmap original;
                    Bitmap mutable = null;
                    try{
                    original = BitmapFactory.decodeResource(this.getResources(), R.drawable.,null);
                    mutable = original.copy(Bitmap.Config.ARGB_8888, true);
                    }catch (Exception e) {
                        // TODO: handle exception
                    }
                    Paint paint=new Paint();
                    paint.setAntiAlias(true);
                    Canvas c= new Canvas(mutable);
                    Log.d("density",""+dm.density);
                    paint.setColor(Color.WHITE);
                    paint.setTypeface(Typeface.DEFAULT_BOLD);
                    paint.setTextAlign(Align.CENTER);   
                    paint.setTextSize(42);
                    c.drawText("text", (mutable.getWidth()/2)-x,(mutable.getHeight()/2)+y, paint);
                    BitmapDrawable bitmap = new BitmapDrawable(mutable)

                    imageView set background drawable bitmap
于 2012-11-21T11:26:38.157 回答