在ImageView中调整图像大小,然后调整imageView的大小

时间:2015-09-28 09:15:32

标签: android xml android-layout imageview

我想要在ImageView中显示一个大的正方形可绘图像 这个很小,因为它必须在高度match_parent LinearLayout。 我希望图像也可以在 width 中调整大小,保持图像的宽高比。 所以我有类似的东西:

<LinearLayout
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:orientation="horizontal">

   <ImageView
      android:layout_width="wrap_content"
      android:layout_height="match_parent"
      android:adjustViewBounds="true"
      android:src="@drawable/image"/>

   <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="text"/>

</LinearLayout>

我期望的是linearlayout测量TextView高度, 然后ImageView获取此高度,最后重新调整其宽度以保持图像宽高比。

相反,ImageView宽度不会重新缩放,而我最终的宽度是ImageView,其中高度 (通过TextView 高度测量)但是原始的,未缩放的可绘制图像的宽度

似乎android:adjustViewBounds="true" 没有工作,最初设置为未缩放图像的wrap_content width 一直保留到最后。

我哪里错了?以及如何让ImageView按照我的要求重新调整?

0 个答案:

没有答案
相关问题