Reputation: 662
Description:
I have 2 button and my one button overlap half the other button.my button have ireegular shapes. Due to which some are in my button have transparent area.the area whic overlap other button.
My problem
When i click on transparent area of button.then touch should be trigered on button below it.I am unable to transfer touch to below button.and vice versa
Explation by picture
explaintion:
rectangle with black color is button and rectangle with light green color is also button and transparent area of light green rectangle button overlap black.
My Accomplishment i have triggered that touched area is transparent area of button or coloured
Bitmap TheBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.menu);
int eventPadTouch2 = event.getAction();
int iXi = (int) event.getX();
int iYi = (int) event.getY();
switch (eventPadTouch2) {
case MotionEvent.ACTION_DOWN:
if (iXi>=0 & iYi>=0 & iXi<TheBitmap.getWidth() & iYi<TheBitmap.getHeight()) {
if (TheBitmap.getPixel(iXi,iYi)!=0) {
Toast.makeText(Mainact2.this, "menu",Toast.LENGTH_LONG).show();
return true;
}
else {
// do work if transparent area
view2.bringToFront();
/*view2.requestFocus();
view2.requestFocusFromTouch();
view2.onTouchEvent(event);
*/
}
}
}
Upvotes: 0
Views: 647
Reputation: 111
you can use this code
getWindow().addFlags(
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
Upvotes: 1
Reputation: 3535
When you detect that the transparent area has been touched (which should trigger touch of the button below), then just call its touch/click handler.
Simplified code:
void btn1OnTouch()
{
if (!transparent)
{
btn1Handler();
}
else
{
btn2Handler();
}
}
void btn2OnTouch()
{
btn2Handler();
}
void btn1Handler()
{
//real job is done here
}
void btn2Handler()
{
//real job is done here
}
Have you tried it this way?
Upvotes: 0
Reputation: 1984
If you can detect that the touch was on a transparent part, then return false from the OnTouchListener. That should pass the touch event down to the next view in that area.
Upvotes: 0