将图像放在图像上
Place image's over image
我正在开发一个 android 应用程序,您可以设置自己的 Ring。
现在我想在用户选择多个戒指时为他们提供戒指的预览。
这里是它应该是什么样子的预览
我想如何制作它的设置是这样的:
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="5dp">
<ImageView
android:id="@+id/generator_ring_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#e7e7e7"/>
<FrameLayout
android:id="@+id/generator_ring_addon_frame"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
</FrameLayout>
我将通过在代码中创建一个新的 ImageView 以编程方式添加插件环。
现在最难的部分是将图像放在另一个环上,并在每个屏幕尺寸上都有相同的视图..
是否有人可以帮助我获得正确的代码,以便将图像放置在每种屏幕尺寸的正确位置?
感谢阅读
编辑:
当我选择附加环时,Base Rings 已经可见,所以我可以获得图像的高度
用户画图 API:https://developer.android.com/reference/android/graphics/Paint.html
https://developer.android.com/reference/android/graphics/Canvas.html
就像那样,您可以通过编程方式添加任何您想要的图片,移动它们,甚至可以根据需要创建动画。
此外,您将只有一个视图,其中包含 canvas。因此无需将 FrameLayouts 复杂化为 FrameLayouts。
关于如何在 canvas 上绘制图像的示例。
draw object/image on canvas
使用canvas你可以得到环的(x,y)坐标。
首先使用环形图像创建 canvas,然后使用 canvas.draw() 在基础图像上绘制另一个图像。
我正在开发一个 android 应用程序,您可以设置自己的 Ring。
现在我想在用户选择多个戒指时为他们提供戒指的预览。
这里是它应该是什么样子的预览
我想如何制作它的设置是这样的:
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="5dp">
<ImageView
android:id="@+id/generator_ring_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#e7e7e7"/>
<FrameLayout
android:id="@+id/generator_ring_addon_frame"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
</FrameLayout>
我将通过在代码中创建一个新的 ImageView 以编程方式添加插件环。
现在最难的部分是将图像放在另一个环上,并在每个屏幕尺寸上都有相同的视图..
是否有人可以帮助我获得正确的代码,以便将图像放置在每种屏幕尺寸的正确位置?
感谢阅读
编辑:
当我选择附加环时,Base Rings 已经可见,所以我可以获得图像的高度
用户画图 API:https://developer.android.com/reference/android/graphics/Paint.html https://developer.android.com/reference/android/graphics/Canvas.html 就像那样,您可以通过编程方式添加任何您想要的图片,移动它们,甚至可以根据需要创建动画。 此外,您将只有一个视图,其中包含 canvas。因此无需将 FrameLayouts 复杂化为 FrameLayouts。 关于如何在 canvas 上绘制图像的示例。 draw object/image on canvas
使用canvas你可以得到环的(x,y)坐标。
首先使用环形图像创建 canvas,然后使用 canvas.draw() 在基础图像上绘制另一个图像。