android - Xamarin, ImageView 问题

标签 android visual-studio xaml xamarin imageview

嗨,我是 xamarin 的新手,我遇到了 imageview 的问题。我的图像是矩形的(1080x293),但在 Imageview 中,底部和顶部的边距似乎是正方形,图像位于中间!我想在顶部对齐图像,尝试使用填充属性,设置宽度和高度但没有任何效果!我怎样才能把它放在最上面? 一些帮助将不胜感激,谢谢你,对不起这个愚蠢的问题! 这是一段代码!

       <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/titleIMG"
        android:layout_marginBottom="0.0dp"
        android:layout_marginTop="0.0dp"/>

最佳答案

几天前我遇到了同样的问题。我刚刚浏览了属性并找到了这个:“adjustViewBounds”,它允许您保留图片的真实比例。 只需将此添加到您的代码中:

android:adjustViewBounds="true"

关于android - Xamarin, ImageView 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39891961/

相关文章:

c# - MVVM 可编辑组合框绑定(bind)

c# - 仅显示来自实体对象的 DataGrid 中的某些列

android - Flutter 的 TextPainter 抛出 '!_needsLayout' : is not true. ' 异常

c++ - 使用具有相对路径的文件的 Visual Studio 单元测试

.net - 几个 Visual Studio 项目提示缺少临时文件,因此无法打开。错误代码&H80070003

c++ - 为什么 int count 在进入循环时从 1 跳到 4? C++

java - 用户轨迹移动标记动画

android - 需要错误 : Gradle version 2. 2。当前版本是 5.1.1

android - 从最大拉伸(stretch)中停止空 ConstraintLayout

c# - 如何在WPF窗口中隐藏关闭按钮?