android - 动态改变imageview的位置

w1c*_*d64 5 layout android dynamic

我目前正在使用矩阵方法为图像实现拖动和缩放缩放(图像A)

现在我希望图像A的一部分可以点击,所以我将另一个图像视图(图像B)放在图像A上,并在xml文件中为它设置layout_margins.

我的问题是......有没有办法动态改变我的layout_margins,因为我正在缩放我的图像以进行拖拽缩放?

我想更简单的问题是......我如何为imageview动态设置layout_margins?

<RelativeLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent" >

   <ImageView android:id="@+id/imageView"
     android:layout_width="fill_parent"
     android:layout_height="fill_parent"
     android:src="@drawable/map"
     android:scaleType="matrix" />

    <ImageView
       android:id="@+id/dundas_station"
       android:layout_width="75px"
       android:layout_height="75px"
       android:layout_marginTop="337px"
   android:layout_marginLeft="373px"
       android:clickable="true"
       android:src="@drawable/google_maps_icon"
       android:scaleType="matrix"
       />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

谢谢!