图像视图裁剪不起作用
imageview-cropping not working
当我尝试 "centerCrop" 或 "center." 时,我的图像视图没有改变,要解决什么问题才能裁剪图像?
<RelativeLayout 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"
tools:context="xx.myapplication.MainActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/party"
android:scaleType="centerCrop" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="From. h"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_margin="8dp"
android:padding="8dp"
android:textSize="20sp"
android:textColor="#FFEBEE"
android:fontFamily="sans-serif-medium" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Happy Wednesday!!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_margin="8dp"
android:textSize="36sp"
android:textColor="@android:color/white"/>
</RelativeLayout>
我在代码中看到的图像:
使用src
代替background
android:src="@drawable/party"
当我尝试 "centerCrop" 或 "center." 时,我的图像视图没有改变,要解决什么问题才能裁剪图像?
<RelativeLayout 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"
tools:context="xx.myapplication.MainActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/party"
android:scaleType="centerCrop" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="From. h"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_margin="8dp"
android:padding="8dp"
android:textSize="20sp"
android:textColor="#FFEBEE"
android:fontFamily="sans-serif-medium" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Happy Wednesday!!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_margin="8dp"
android:textSize="36sp"
android:textColor="@android:color/white"/>
</RelativeLayout>
我在代码中看到的图像:
使用src
代替background
android:src="@drawable/party"