自定义ImageView getScaledHeight

时间:2018-07-30 15:03:51

标签: android imageview height scale

我有位图尺寸为250x250的CustomImageView,根据xml中设置的以下属性,该视图在FrameLayout中被放大,屏幕尺寸为aprox“ 1500x700”;

<FrameLayout
        android:id="@+id/m_Frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:foregroundGravity="clip_horizontal|clip_vertical"
        tools:ignore="true">
        <com.package.app.custImageView
            android:id="@+id/artView"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:alpha="0.4"
            android:padding="10dp"/>
    </FrameLayout>

通过此操作,可以通过保持宽度宽高比来设置ImageView以匹配父级高度。

在此之后,当我尝试读取“ bitmap.getScaledHeight(canvas);”时在CustomImageView类的onDraw属性上,它仍然为我提供了原始的位图像素大小为250。

有人可以指导我,如何在自动缩放的图像上阅读“ getScaledHeight / getScaledWidth”或新尺寸/坐标? ImageView layout represntation

0 个答案:

没有答案