Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
您必须在代码中执行此操作:
确定显示尺寸(或图像容器的尺寸)。
然后计算图像显示/容器尺寸的比率。这将为您提供调整覆盖图像大小所需的比率。
最后使用计算出的比率计算需要再次放置覆盖层的位置的调整大小坐标。
你已经完成了:)
编辑
你可以在xml中的ImageViews中设置一个参数吗?
android:adjustViewBounds="true"
You will have to do it in code:
Determine the display dimensions (or the dimensions of the container of the image).
Then calculate the ratio of the image-display/container size. This will give you the ratio by which you need to re-size your overlay image.
Last calculate the re-sized coordinates of the position in which you need to place the overlay again using the calculated ratio.
You are done :)
EDIT
can you set a parameter in your ImageViews in xml?
这对我有用。传递两个位图图像以相互叠加。
public static Bitmap overlay(String patho,String patht) { Bitmap bmp1= BitmapFactory.decodeFile(patho); Bitmap bmp2= BitmapFactory.decodeFile(patht); Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig()); Canvas canvas = new Canvas(bmOverlay); Matrix m=new Matrix(); canvas.drawBitmap(bmp1, m, null); canvas.drawBitmap(bmp2, m,null); return bmOverlay; }
It works for me. Pass two bitmap images to overlay each other.
我不确定我是否 100% 理解你想要做什么,但如果你想对屏幕上的图像进行那么多控制,那么你应该考虑 SurfaceView,查看 SDK 附带的 LunarLander 示例。
I'm not sure if I 100% understand what you're trying to do, but if you want that much control over images on a screen then you should consider SurfaceView, check out the LunarLander example that comes with the SDK.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
发布评论
评论(3)
您必须在代码中执行此操作:
确定显示尺寸(或图像容器的尺寸)。
然后计算图像显示/容器尺寸的比率。这将为您提供调整覆盖图像大小所需的比率。
最后使用计算出的比率计算需要再次放置覆盖层的位置的调整大小坐标。
你已经完成了:)
编辑
你可以在xml中的ImageViews中设置一个参数吗?
You will have to do it in code:
Determine the display dimensions (or the dimensions of the container of the image).
Then calculate the ratio of the image-display/container size. This will give you the ratio by which you need to re-size your overlay image.
Last calculate the re-sized coordinates of the position in which you need to place the overlay again using the calculated ratio.
You are done :)
EDIT
can you set a parameter in your ImageViews in xml?
这对我有用。传递两个位图图像以相互叠加。
It works for me. Pass two bitmap images to overlay each other.
我不确定我是否 100% 理解你想要做什么,但如果你想对屏幕上的图像进行那么多控制,那么你应该考虑 SurfaceView,查看 SDK 附带的 LunarLander 示例。
I'm not sure if I 100% understand what you're trying to do, but if you want that much control over images on a screen then you should consider SurfaceView, check out the LunarLander example that comes with the SDK.