2010-11-30 10 views
5

の位置を変更アンドロイド - 動的iは現在の画像(画像A)のドラッグとピンチズームを実現するために、マトリックス法を使用しているImageViewの

今は画像Aの部分がクリック可能にしたいので、私画像Aの上に別の画像ビュー(画像B)を置き、そのためのlayout_marginsをxmlファイルに設定します。

私の質問はドラッグ&ピンチズーム用にイメージを拡大しているので、layout_marginsを動的に変更する方法はありますか?

私は簡単な質問は...私はどのように動的に画像ビューの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> 

ありがとうございました!

答えて

0

あなたは、コードスニペット以下setMargins

4

使用を使用しています。 Don3530をインポートするのを忘れないでください。 "android.widget.FrameLayout.LayoutParams"または余分なレイアウトパラメータ。

ImageView image; 
LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); 
params.setMargins(100,0, 0,0); 

// OR 
params.topMargin= 100; 
image.setLayoutParams(params); 
関連する問題