我有兩個二ImageView
不同的佈局中,一個ImageView
是另一個ImageView
,我使用RelativeLayout
&兩個ImageView
大小包裹的內容,但如果我上ImageView2
單擊時間Imageview2
顯示在Imageview1
和問題如果我點擊ImageView1
,那麼Imageview1
會顯示在Imageview2
上我正在使用引導式方法,但這不起作用。對不起英文交流。請幫幫我。如何獲取ImageView帶來ImageView的觸摸事件?
在此先感謝
以下是我的代碼。
的main.xml: -
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout android:layout_width="fill_parent" android:id="@+id/mRlayout1"
android:layout_height="fill_parent">
<ImageView android:layout_width="wrap_content"
android:scaleType="matrix" android:layout_height="wrap_content"
android:id="@+id/mImageView1" android:src="@drawable/icon1" />
</RelativeLayout>
<RelativeLayout android:layout_width="fill_parent" android:id="@+id/mRlayout2"
android:layout_height="fill_parent" >
<ImageView android:layout_width="wrap_content"
android:scaleType="matrix" android:layout_height="wrap_content"
android:id="@+id/mImageView2" android:src="@drawable/icon" />
</RelativeLayout>
</RelativeLayout>
Java文件: -
public class BodyTemp extends Activity {
ImageView mImageView1, mImageView2;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mImageView1 = (ImageView) findViewById(R.id.mImageView1);
mImageView1.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
mImageView1.bringToFront();
return true;
}
});
mImageView2 = (ImageView) findViewById(R.id.mImageView2);
mImageView2.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
mImageView2.bringToFront();
return true;
}
});
}
}
你能詳細描述一下mspaint中的圖片嗎?所以我們可以更好地理解和解決 –
你好,尼克,我編輯了我的問題,並把代碼。 –
究竟你想做什麼?你還沒有清楚你想要什麼。 –