【问题标题】:Bitmap that is larger Width than Height appears landscaped in ImageView宽度大于高度的位图在 ImageView 中显示为横向
【发布时间】:2014-01-15 14:52:41
【问题描述】:

我从服务器获取的位图比它的高度更宽,例如高度 = 612,宽度 = 816,并将其放入 ImageView 中,即高度 = 568 和宽度 = 320。来自服务器的图像在 imageview 中显示为横向,也就是说,它出现在它的一侧。 However 我想缩放它以适应 ImageViews 尺寸。我尝试了很多不同的比例类型,fitXY 我认为会修复它,但它仍然是一样的。下面是我的xml:

<ImageView
    android:id="@+id/imageView1"
    android:adjustViewBounds="true"
    android:layout_width="320dp"
    android:layout_height="568dp"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:scaleType="fitXY"
    /> 

【问题讨论】:

  • 缩小位图
  • 我也试过了,但几乎看不懂

标签: android bitmap android-imageview


【解决方案1】:

这样使用:

在 res 文件夹中: 制作价值土地文件夹 然后制作dimen.xml 将这些高度宽度值放入其中

喜欢:

 <dimen name="image_widht">816dp</dimen>`
<dimen name="image_height">612dp</dimen>

在您的图像视图中:

<ImageView
    android:id="@+id/imageView1"
    android:adjustViewBounds="true"
    android:layout_width="@dimen/image_widht"
    android:layout_height="@dimen/image_heigh"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:scaleType="fitXY"
    />

您还为 potrate 在 value 文件夹中创建了维度 xml 并将具有相同名称的维度与您想要的不同值放在一起

【讨论】:

  • 这有什么帮助,你能进一步解释一下吗?
  • 当改变方向时,它会自动为维度绘制 value-land 文件夹
  • 我不想在设备方向改变时改变图像。当设备处于纵向模式时,来自服务器的图像显示为横向。请看上面
  • 有什么问题可以问我
  • 兄弟它的工作我已经在我的代码中实现了。我觉得你错过了一些东西。您正在 value 和 value-land 文件夹中创建两个文件 dimens.xml 并在两个 dimen.xml 文件中给出高度和宽度相同的维度名称
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-05-15
  • 1970-01-01
相关资源
最近更新 更多