I am working on the App "KISS ME" , in which when a user touch the background image a paste of the lips left behind where he touches the image .... I want that whenever a user touches the image other than the face of the girl , the paste don't show up ...Paste only shows on the face how can i do it only for the face??? Kindly help me out i have googled it but couldn't find anything
Here is my Main.java
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
linearLayout = (RelativeLayout) findViewById(R.id.kt);
spool = new SoundPool(3, AudioManager.STREAM_MUSIC, 0);
spool.setOnLoadCompleteListener(new OnLoadCompleteListener() {
@Override
public void onLoadComplete(SoundPool soundPool, int sampleId,
int status) {
Log.i("OnLoadCompleteListener", "Sound " + sampleId
+ " loaded.");
boolean loaded = true;
}
});
linearLayout.setOnTouchListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
Log.d("TAG for onCreatMenu", "Called");
MenuInflater mInflater = getMenuInflater();
mInflater.inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.lt:
Intent i = new Intent(Main.this, LipseListView.class);
startActivity(i);
return true;
case R.id.bi:
Intent b = new Intent(Main.this, BackgroundList.class);
startActivity(b);
return true;
case R.id.ls:
Intent s = new Intent(Main.this, SoundList.class);
startActivity(s);
return true;
case R.id.exit:
AlertDialog alertbox = new AlertDialog.Builder(this)
.setMessage("Do you want to exit application?")
.setPositiveButton("Yes",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0,
int arg1) {
finish();
}
})
.setNegativeButton("No",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0,
int arg1) {
}
}).show();
default:
return false;
}
}
@Override
protected void onResume() {
super.onResume();
linearLayout
.setBackgroundResource(BackgroundList.images[BackgroundList.position2]);
this.soundId = this.spool.load(this,
SoundList.sound[SoundList.position3], 1);
}
@Override
public boolean onTouch(View arg0, MotionEvent event) {
int action = event.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
downx = event.getX();
downy = event.getY();
runImage = new ImageView(Main.this);
runImage.setBackgroundResource(LipseListView.images[LipseListView.position]);
androidanimation = (AnimationDrawable) runImage.getBackground();
runImage.setX(downx);
runImage.setY(downy);
linearLayout.addView(runImage);
androidanimation.start();
spool.play(soundId, 1, 1, 1, 0, 1);
break;
case MotionEvent.ACTION_UP:
upx = event.getX();
upy = event.getY();
this.linearLayout.invalidate();
runImage.setBackgroundResource(0);
ImageView img = new ImageView(this);
img.setX(upx);
img.setY(upy);
img.setBackgroundResource(LipseListView.images[LipseListView.position]);
linearLayout.addView(img);
Bitmap cameraBitmap = BitmapFactory.decodeResource(getResources(),
BackgroundList.images[BackgroundList.position2]);
int wid = cameraBitmap.getWidth();
int hgt = cameraBitmap.getHeight();
Bitmap newBitmap = Bitmap.createBitmap(wid, hgt,
Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(newBitmap);
canvas.drawBitmap(cameraBitmap, 0f, 0f, null);
Drawable drawable = getResources().getDrawable(
R.drawable.ic_launcher);
drawable.setBounds(20, 30, drawable.getIntrinsicWidth() + 20,
drawable.getIntrinsicHeight() + 30);
drawable.draw(canvas);
break;
case MotionEvent.ACTION_CANCEL:
break;
default:
break;
}
return true;
}
}
Here is my main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/kt"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="false"
tools:context=".Main" >
</RelativeLayout>