【发布时间】:2015-04-27 18:37:26
【问题描述】:
我有一个在 XML 中定义如下的 ImageView。它位于自定义 ViewPager 中。
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView"
android:scaleType="fitXY"/>
它就像一个魅力,但我需要知道图像的实际高度,在它被缩放之后。我正在使用自定义 ViewPager 的 onMeasure 方法中的值,如下所示:
View child = getChildAt(0);
child.measure(widthMeasureSpec, MeasureSpec
.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
int h = child.getMeasuredHeight();
我得到的高度不是缩放后的图像高度,而是缩放前图像的原始尺寸。
谢谢。
【问题讨论】:
标签: android imageview runtime size scale