TheLettuceMaster
TheLettuceMaster

Reputation: 15734

Disable Touch on Background Fragment

I have a Main FragmentActivity that displays the main app fragments. I have one particular fragment that I open on top of the "behind" main Fragment. It only slide about 90% over with an animation. My problem is this:

In that small 10% of the "behind" fragment that still shows through, you can manipulate it. For example, it's a ListView, so I can scroll.

Is there a way to "turn off" or make the background fragment inactive here no touch responses happen?

Upvotes: 3

Views: 5152

Answers (2)

Mikelis Kaneps
Mikelis Kaneps

Reputation: 4584

Just to add to Shashidhar Manchu answser: Add:

android:clickable="true" android:background="#000"

For example:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/LinearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#000"
    android:orientation="vertical" 
    android:clickable="true">

<View
            android:id="@+id/sampleChild"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>

</LinearLayout>

The background is optional, but without it, the fragment in the background will be visible.

Upvotes: 8

SHASHIDHAR MANCHUKONDA
SHASHIDHAR MANCHUKONDA

Reputation: 3322

return true for that view in ontouchlistener. or you can make transaprent layout (with fill parent height and width in xml) when fragment added make your transaperent layout clickable true and when fragament removed make it false.

Upvotes: 3

Related Questions