6

Is it possible in android that one transparent activity is on the top and a background activity is able to handle the events?

If yes then please refer the below image enter image description here

As in image i have one activity in background with button click and another activity with drawer. And i want that button in the background activity can able to handle events.

Deepak Goel
  • 5,624
  • 6
  • 39
  • 53

2 Answers2

14

I was able to make this work with the following code in my transparent foreground activity

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Pass touch events to the background activity
        getWindow().addFlags(
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                        | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
                        | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
...
        setContentView(R.layout.main);
}
marmor
  • 27,641
  • 11
  • 107
  • 150
3

I have never tried, but creating a SlidingDrawer with a Fragment inside should work.

Using the Compatibility library will work till android 1.6!

 <SlidingDrawer
     android:id="@+id/drawer"
     android:layout_width="match_parent"
     android:layout_height="match_parent"

     android:handle="@+id/handle"
     android:content="@+id/content">

<fragment android:name="your.package.name.yourFragment"
        android:id="@+id/fragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

 </SlidingDrawer>

On your button, you will add:

public void animateOpen ()

Since: API Level 3 Opens the drawer with an animation.

Waza_Be
  • 39,407
  • 49
  • 186
  • 260
  • Ya thanks for your response i got your point but my question actually that the sliding drawer is not included in same activity it itself in the other activity with translucent theme.and till the drawer is not open is it possible that background activity can take events – Deepak Goel Jan 02 '12 at 10:14
  • As you can see in your question comment, working with 2 separate activities is NOT POSSIBLE. If you work with fragment, that are totally similar to activities, that will work and is in my mind the only proper way to achieve what you want. – Waza_Be Jan 02 '12 at 10:44
  • OK that is what i want to know.Thanks for your response. – Deepak Goel Jan 03 '12 at 03:17