当前位置: 首页 > 知识库问答 >
问题:

图像未覆盖全部背景

傅树
2023-03-14

我正在构建一个聊天应用程序,当我向用户发送一个图像时,图像并没有覆盖我给出的背景,而是给出了顶部和底部的有线填充。如何解决这个问题。我给出的填充是每边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>

共有1个答案

韦宏扬
2023-03-14

您需要使用

android:scaleType="fitXY"

Scale类型有许多值,如Matrix、fitXY、fitStart、fitCenter、firEnd、center、CenterCraft、CenterInside

使用fitxy,如果您选择match_parent或您想要的length and widt,它将覆盖所有屏幕

<ImageView
        android:id="@+id/image"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="fitXY"
        android:src="@drawable/ic_background_image" />
 类似资料:
  • 问题内容: 我有一个。当用户悬停div时,我想用rgba颜色()覆盖背景图像。 我想知道是否有一个一格解决方案(即没有多个div,一个用于图像,一个用于颜色,等等)。 我尝试了多种方法: 而这个CSS: 我看到的唯一选择是制作另一个具有覆盖层的图像,使用JavaScript预加载然后使用。但是,我想要一个仅CSS的解决方案(更整洁;更少的HTTP请求;更少的硬盘)。有没有? 问题答案: Peter

  • 正如这里所讨论的,我试图在div中覆盖一幅图像。仅用这些简单的线条,我就可以通过背景图像来实现这一点: 结果图像在div中居中并调整大小以适应div的宽度或高度(取决于图像是否宽)。现在我想在div中使用图像标签实现相同的结果。 有没有办法用普通的CSS来解决这个问题?

  • 背景图像在大屏幕上不显示为完整图像,但在小屏幕上很合适。 在所有的屏幕上,图像都有一个特定的维度来作为响应?

  • 因此,我正在创建一个代表自动售货机的GUI。我只是遇到了一些问题,试图让布局按我想要的方式工作。我的想法是在JLabel中插入一个图像,然后在特定位置用透明JButton覆盖该图像,这样当您在特定位置单击图像时,它将触发JButton。我还没有达到透明性,因为我目前正专注于如何将JButton精确地放置在需要的位置。 我已经尝试过setLoctionandsetBound,但没有成功。任何关于如何

  • 假设我们正在运行一个程序,我们想从当前程序运行另一个程序。 这可能吗? 如果我们实施覆盖过程映像的概念,为什么不呢。 那很好但是当前正在运行的程序呢,也可以运行。 怎么可能,因为我们将当前的计划与新计划重叠。 该怎么做,如果我想在不丢失当前正在运行的程序的情况下运行这两个程序,是否可能? 对的,这是可能的。 创建子进程,以便我们有一个父进程和一个新创建的子进程。 我们已经在父进程中运行当前程序,因

  • 我有一个图像,我想覆盖在地图上的特定位置,看起来像当前静态地图图像服务没有提供任何参数传递。