How to launch a transparent activity so that background activity is able to take events

后端 未结 2 333
不思量自难忘°
不思量自难忘° 2021-01-12 17:04

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 imag

相关标签:
2条回答
  • 2021-01-12 17:50

    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);
    }
    
    0 讨论(0)
  • 2021-01-12 17:55

    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.

    0 讨论(0)
自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题