[英]How to Put image inside another image view
i want to put sticker view completely inside the image view( it should not go out of image boundary)我想将贴纸视图完全放在图像视图中(它不应该超出图像边界)
image view is uploaded by user so it cannot be a fixed size.I can do adjustments on sticker size if needed current sticker size (540x670)图像视图由用户上传,因此它不能是固定尺寸。如果需要,我可以调整贴纸尺寸当前贴纸尺寸(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>
Since my comment helped solve, I'll just post in the answer then.由于我的评论帮助解决了,所以我会在答案中发布。
Just create a container layout like
FrameLayout
that'll be exactly the size of the image (wrap_content
) and then add theStickerView
inside that.只需创建一个像
FrameLayout
这样的容器布局,它与图像的大小(wrap_content
)完全相同,然后在其中添加StickerView
。
Something like this:像这样的东西:
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<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" />
</FrameLayout>
尝试使用约束布局并将贴纸的约束设置到图像视图的内部。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.