简体   繁体   English

将图像设置在x,y图像内

[英]Set image inside x,y image

Its possible to set any image inside other image in the pixel coordenates what i want? 可以在像素中的其他图像内设置任何图像来协调我想要的内容吗?

First image is a big image, and the second image is a sign of a user. 第一图像是大图像,第二图像是用户的标志。

I think witch canvas this is posible but i am not sure. 我认为这是可以的,但我不确定。

Anyone have a example of this? 有人举这个例子吗?

You can use FrameLayout , make big image to be the background and the little one to be on the foreground. 您可以使用FrameLayout ,将大图像作为背景,将小图像作为前景。 You can change its gravity using the android:layout_gravity attribute. 您可以使用android:layout_gravity属性更改其重力。 FrameLayout documentation here . FrameLayout文档在这里 Hope this helps. 希望这可以帮助。

You could make the first image the content of a class that extends from ImageView. 您可以使第一个图像成为从ImageView扩展的类的内容。 Then in this class, override onDraw(Canvas canvas), drawing the second the image as a Bitmap at the coordinates you specify. 然后在此类中,重写onDraw(Canvas canvas),在您指定的坐标处将第二个图像绘制为位图。

Eg 例如

public class DoubleImage extends ImageView
{
    private Bitmap mSecondBitmap;
    public DoubleImage(Context context, AttributeSet attrs)
    {
         super(context, attrs);

         // load the second image into mSecondBitmap
         mSecondBitmap = BitmapFactory.decodeResource(context, R.drawable.my_second_image);
    }

    @Override
    protected void onDraw(Canvas canvas)
    {
        super.onDraw(canvas);

        canvas.drawBitmap(mSecondImage, x, y, null);
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM