Reputation: 69
I want to disable touch event in android except the certain area of screen and when the user double tab that specific area of screen it gets enable. Any kind of help is appreciated!
Upvotes: 1
Views: 2881
Reputation: 357
You to disable touch event in except the specific area of screen
Step 1:Mention that Area with Specific ID Eg)
<EditText
android:id="@+id/sample_edt"
android:layout_width="match_parent"
android:layout_height="@dimen/margin50"
android:background="@null" />
Step 2:Initial that ID in your Activity or Fragment Eg)
EditText mSampleEdt = (EditText) findViewById(R.id.sample_edt);
Step 3:Disable you touch and focus in that area Eg)
mSampleEdt .setFocusable(false);
mSampleEdt .setFocusableInTouchMode(false);
mSampleEdt .setClickable(false);
Step 4:Suppose you want again visible that focus and touch means you need to enable that focus part.
mSampleEdt .setFocusable(true);
mSampleEdt .setFocusableInTouchMode(true);
mSampleEdt .setClickable(true);
Upvotes: 1
Reputation: 19474
There are a number of ways to do this. Here's one: create a view as a child of your activity's screen view. Position the child exactly over the area where you want to detect double tap. Then handle the double tap in that view and ignore it in the parent view.
The child view can be made transparent.
Upvotes: 0