Transparent Activity with background activity click through behaviour in android

后端 未结 2 1468
星月不相逢
星月不相逢 2021-01-02 12:08

Hi stackoverflow I\'m trying to develop an application with a base activity and a Transparent activity, so far I\'m able to create a Activity

相关标签:
2条回答
  • 2021-01-02 12:22

    Add these lines in the Transparent Activity above super.onCreate() method.

    getWindow().setFlags(LayoutParams.FLAG_NOT_TOUCH_MODAL,
                LayoutParams.FLAG_NOT_TOUCH_MODAL);
    
        // ...but notify us that it happened.
    getWindow().setFlags(LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
                LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);
    

    transparent layout like this..

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:padding="8dp" >
    
    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="29dp"
        android:layout_marginRight="44dp"
        android:text="Button" />
    

    0 讨论(0)
  • You can use this code on your foreground activity

    getWindow().addFlags(
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                        | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
                        | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
    
    0 讨论(0)
提交回复
热议问题