Reputation: 6188
I have a layout inside another layout.
<GridLayout ... >
<RelativeLayout android:id="@+id/id_daily_readings_small" ... > ... </RelativeLayout>
</GridLayout>
I want to add a touch event to the relative layout and all its contents so that touching anywhere inside it will fire the event. How can this be done?
Upvotes: 0
Views: 23
Reputation: 44571
Try something like
RelativeLayout rl = (RelativeLayout) findViewById(R.id.id_daily_readings_small);
rl.setOnTouchListener(new OnTouchListener()
{
@Override
public void onTouch(View v, MotionEvent event)
{
// do your work
}
});
Then you can compare the MotionEvent
to decide what to do if you want to change the behavior based on pressing down/up/etc... Check the Docs links below for more information to make it work for what exactly you need.
Upvotes: 1