public class GameActivity extends the Activity {
@ SuppressLint (" ClickableViewAccessibility ")
@ Override
Protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
The setContentView (R.l ayout. Activity_game);
FrameLayout frameLayout1=the findViewById (R.i d.m yView);//create the frame layout manager
Final RabbitView2 bear=new RabbitView2 (GameActivity. This);
Bear. SetOnTouchListener (new the OnTouchListener () {//add touch event listener
@ Override
Public Boolean the onTouch (View v, MotionEvent event) {
Bear. BitmapX=event. GetX ();//set the X coordinate
Bear. BitmapY=event. GetY ();
Bear. Invalidate ();
return true;
}
});
FrameLayout1. AddView (bear);//added to the layout manager
FrameLayout frameLayout2=the findViewById (R.i d.m yView);//create the frame layout manager
Final SheepView sheep=new SheepView (GameActivity. This);
Sheep. SetOnTouchListener (new the OnTouchListener () {//add touch event listener
@ Override
Public Boolean the onTouch (View v, MotionEvent event) {
The sheep. BitmapX=event. GetX ();//sets the initial X display
The sheep. BitmapY=event. GetY ();
The sheep. Invalidate ();//redraw component
return false;
}
});
FrameLayout2. AddView (sheep);//added to the layout manager
}
}
CodePudding user response:
Below one is trueCodePudding user response:
Had tried the return value, the following also returns true when the picture is completelyCodePudding user response:
That means you have a picture 2 size problem, completely hides behind the controls