[英]Image is not covering full background
我正在构建一个聊天应用程序,当我向用户发送图像时,该图像没有覆盖我给定的背景,而是在顶部和底部提供了有线填充。 如何解决这个问题。 我给的每一边的填充是7dp,这是我的代码
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">
<android.support.constraint.ConstraintLayout
android:layout_width="wrap_content"
android:id="@+id/photo"
android:background="@drawable/toolbar_background"
app:layout_constraintRight_toRightOf="parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/imageContentUser"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:src="@drawable/doc"
android:padding="0dp"
android:adjustViewBounds="true"
app:layout_constraintRight_toRightOf="parent" />
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
您需要使用
android:scaleType="fitXY"
比例类型具有许多值,例如matrix, fitXY, fitStart, fitCenter, firEnd, center, centerCrop, centerInside
您使用fitXY
,如果您将其选择为match_parent
或可能所需的length and width
,它将覆盖整个屏幕
最终应该是这样的:
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="@drawable/ic_background_image" />
希望这对您有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.