I've a AbsoluteLayout
and I wanna move my ImageView
around this Layout trough my touch points , Look at my code , Everything is fine when I touch any points, Points are saved in a variable , but ImageView
was disappear , Any Ideas?
My XML Layout :
<ImageView
android:id="@+id/FirstBall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="59dp"
android:layout_y="446dp"
android:src="@drawable/redball" />
</AbsoluteLayout>
My Codes:
FstBall=(ImageView)findViewById(R.id.FirstBall);
FstBall.setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View v, MotionEvent event) {
float x = event.getX();
float y = event.getY();
int action = event.getAction();
float FnlResX = 0;
float FnlResY = 0;
if (action == MotionEvent.ACTION_MOVE){
FnlResX = x;
FnlResY = y;
int tst1 = (int) FnlResX;
int tst2= (int) FnlResY;
FstBall.scrollBy(tst1, tst2);
}
return true;
}
});