在android studio中设置imageview
我正在尝试添加3个带有文本的imageview,但是我的图像有问题 在图像下方和上方都有一些emty空间,因此图像就像一个正方形。 我无法更改其他图像和文本。 它就像图像周围的一层 像这样: 这是我的密码在android studio中设置imageview,android,Android,我正在尝试添加3个带有文本的imageview,但是我的图像有问题 在图像下方和上方都有一些emty空间,因此图像就像一个正方形。 我无法更改其他图像和文本。 它就像图像周围的一层 像这样: 这是我的密码 <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.andr
<androidx.constraintlayout.widget.ConstraintLayout 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=".MainActivity">
<ImageView
android:id="@+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/tuna" />
发生这种情况是因为您的图像文件。它由透明像素组成
如果要手动添加图像,可以使用photoshop删除这些图像。或者,如果您是从服务器获取该图像,请尝试在下面的答案中通过代码将其删除 尝试使用照片编辑器(例如Adobe photoshop)调整图像文件的宽度和高度。将adjustViewBounds设置为true,并使用比例类型进行调整 尝试在imageview中添加这个
android:scaleType=“center”
。