【发布时间】:2023-03-10 01:57:01
【问题描述】:
我想将贴纸视图完全放在图像视图内(它不应该超出图像边界)
图像视图由用户上传,因此它不能是固定尺寸。如果需要,我可以调整贴纸尺寸当前贴纸尺寸 (540x670)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<RelativeLayout
android:id="@+id/relativemain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:gravity="center">
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center_vertical"
android:indeterminateDrawable="@drawable/progress"
android:visibility="gone" />
<ImageView
android:id="@+id/ic_img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/blue_900"
android:layout_centerInParent="true"
/>
<com.A.B.C.StickerView.StickerView
android:id="@+id/stickerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:visibility="visible" />
</RelativeLayout>
</RelativeLayout>
【问题讨论】:
-
我不确定我是否完全遵循。哪个图像需要遍历哪个图像?无论如何,基本的想法是使用
FrameLayout来包装ImageView,然后在其中添加第二个。 -
灰色图像(贴纸视图)应在图像视图(海图)中可见。图像中标记的白色部分应不可见。
-
是的,好吧,现在更清楚了。只需创建一个像
FrameLayout这样的容器布局,该布局将与图像 (wrap_content) 的大小完全相同,然后在其中添加StickerView -
哪个布局应该替换为 FrameLayout(相对或线性)
-
它成功了,谢谢(请将其作为答案发布,以便我接受)
标签: android xml android-studio android-layout imageview