【发布时间】:2014-10-08 06:36:40
【问题描述】:
我在获取图像视图顶部和左侧位置时遇到问题。
我的图像视图设置在相对布局的中心。
当我使用 getleft() 和 getTop() 时,我的结果是 0 和 0。
我的布局文件是:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rlMain"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:scaleType="center"
android:src="@drawable/ic_launcher" />
</RelativeLayout>
这对我来说真的很紧急。
我的问题:
我编写了一个用于移动和缩放图像视图的代码,该代码可以正常工作,但是在第一次单击时,图像视图位置更改为 0、0,我想获取默认位置以防止在第一次单击时发生更改。
【问题讨论】:
-
向我们展示您当前的代码?你什么时候打电话给
getLeft()和getTop()? -
我通过 id 定义了我的图像视图并想要 Toast 它的位置,我怎样才能在 api 级别 8 上烤图像视图位置?
-
你在 onCreate 中调用
getLeft()和getTop()吗? -
是的,当调用 getTop() 和 getLeft() 我看到 0 , 0 但我的图像设置在屏幕中心和 0, 0 不正确
标签: android image view get position