Android ImageView居中图像,具有马赫数父高度
我需要为肖像模式创建ImageView,如下图所示: 但无论我做什么,我都得到了相同的结果,比如: 已编辑Android ImageView居中图像,具有马赫数父高度,android,imageview,Android,Imageview,我需要为肖像模式创建ImageView,如下图所示: 但无论我做什么,我都得到了相同的结果,比如: 已编辑 XML第三幅图像中的示例 <ImageView android:id="@+id/image" android:layout_width="match_parent" android:layout_height="match_parent" android:scaleType="centerCrop" android:adjustViewB
XML
第三幅图像中的示例
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
android:layout_gravity="start"
android:src="@drawable/background" />
几乎没有可能导致此问题。您可以为图像设置边距(上边距和下边距)。或者父布局具有填充(也包括顶部和底部) 只需删除此填充或边距,视图即可填充父布局
还有另一种可能性,通过查看代码,这可能是问题所在。您可能想使用
android:background
属性而不是android:src
请发布负责此部分的xml请发布完整的layout.xml文件。谢谢,它正在工作。我添加了layout_marginTop=“0dp”和layout_marginBottom=“0dp”,它可以按照我的要求工作。我会在5-6分钟内给你评分。我不理解“改变图像可见部分”部分,但无论如何,这是一个不同的问题,请开始一篇新的帖子来问这个问题:)