android - Android中如何删除ImageView的额外空间

标签 android android-layout

我想在项目中使用 imageView ,但它显示了布局中的其他空间。如何删除多余的空间?

此图显示了问题:

example image

XML代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    tools:context="com.tellfa.smsbox.activities.Dialog_image_show">

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:src="@drawable/cover_menu_bg" />

    </RelativeLayout>

</RelativeLayout>

我不想使用 android:scaleType =“centercrop”

最佳答案

使用像这些

的 ImageView
<ImageView
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:adjustViewBounds="true"
   android:src="@drawable/icon"
   android:id="@+id/imv"
   android:scaleType="fitCenter" />

关于android - Android中如何删除ImageView的额外空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34129120/

相关文章:

java - 自定义 AlertDialog 更改/覆盖状态栏颜色,那么我该如何解决这个问题?

java - 关于新对象

java - 为什么你不应该在constraintlayout中使用match_parent?

android - 更改 Place Autocomplete Fragment 的前景色和背景色

android - 类似 evernote 的操作栏 - 向上按钮和选项卡在顶部的一行中,菜单操作在底部

java - 如何使用改造库

android - 用于动态 json 键值的 Gson 解析器类 - Android

android - 如何在Android中从位图中裁剪圆形区域

android - Xamarin Zxing 条形码扫描仪覆盖

java - 如何更改应用程序 :elevation programmatically