为什么getScaleY()总是返回1.0吗? [Android版] [英] Why does getScaleY() always returns 1.0? [Android]
问题描述
我有一个的ImageView
包含图像。此图片是越来越缩放到适合屏幕内,因为它太大了。
I have an ImageView
that contains an image. This image is getting scaled to fit within the screen because it's too large.
我试图找出形象已多少比例使用 getScaleY()
和 getScaleX()
。这的应的回报 1.0
如果图像尚未缩放和返回某个值小于 1.0
如果图像按比例缩小以适合视图。
I'm trying to find out how much the image has scaled using getScaleY()
and getScaleX()
. This should return 1.0
if the image has not been scaled and return some value less than 1.0
if the image is scaled down to fit the view.
相反, getScaleX()
和 getScaleY()
alsways符 1.0
我是否将图像缩小或没有。
Instead, getScaleX()
and getScaleY()
alsways return 1.0
for me whether the image is scaled down or not.
您可以在这里看到我的XML:
You can see my XML here:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/docImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@drawable/dossier_cover"
android:adjustViewBounds="true"
android:padding="0dp"
/>
</RelativeLayout>
有谁知道为什么发生这种情况?还是我以不同的方式我更好查不到规模有多大?
Does anyone know why this is happening? Or am I better off finding out the scale in a different way?
推荐答案
这是因为我叫 getScaleX()
它被画之前。
解开了谜底。
It was because I called getScaleX()
before it was drawn.
Mystery solved.
这篇关于为什么getScaleY()总是返回1.0吗? [Android版]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!