【发布时间】:2016-03-09 08:54:37
【问题描述】:
您好,我需要帮助,因为我正在 在我的 android xml 文件中添加一个 ImageView,并且我在其上方和下方得到了一个 额外空间 我试图查看以下选项我可以用来删除它其中之一是添加android:adjustViewBounds="true"
但是当我这样做时,它会完全删除我的操作栏,下面是我的代码
<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="match_parent"
tools:context="com.example.fred.yebo.MainFragment">
<ImageView
android:id="@+id/yeboAdd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/dice"
/>
</RelativeLayout>
【问题讨论】:
-
android:scaleType="fitXY" 但它可以使您的图像拉伸。
-
它不起作用它会拉伸图像并降低分辨率
-
通常有两种解决方案,第一个是 fitXy,它会拉伸你的图像,第二个是你应该使用 wrap_content 宽度而不是匹配父项
-
我将代码更改为 wrap_content ,但图像仍然看起来不错@VivekMishra
-
除非硬编码图像的宽度和高度,否则无法让它看起来很好
标签: android android-layout android-studio android-imageview android-relativelayout