我想将贴纸视图完全放在图像视图内(它不应超出图像边界)
图片视图是由用户上传的,因此不能为固定尺寸。如果需要,我可以调整标签尺寸(当前标签尺寸为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
,使它与图像(wrap_content
)的大小完全相同,然后StickerView
在其中添加即可。
像这样:
<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>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句