要保证在Dialog遮挡时动画不停止,可以使用WindowManager.LayoutParams中的FLAG_NOT_FOCUSABLE标志来设置Dialog的属性。具体步骤如下:

  1. 创建一个自定义的Dialog,并在构造方法中设置WindowManager.LayoutParams的属性。代码如下:
public class CustomDialog extends Dialog {

    public CustomDialog(Context context) {
        super(context);
        WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
        layoutParams.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
        getWindow().setAttributes(layoutParams);
    }
}
  1. 在Activity中引用PAGView,并在需要显示Dialog的地方调用CustomDialog的show()方法。代码如下:
public class MainActivity extends AppCompatActivity {

    private CustomDialog mDialog;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        PAGView pagView = findViewById(R.id.pag_view);
        // 设置PAGView的动画

        // 显示Dialog
        mDialog = new CustomDialog(this);
        mDialog.show();
    }
}

通过设置FLAG_NOT_FOCUSABLE标志,可以保证Dialog不会获取焦点,从而不会影响PAGView的动画

android Activity中引用PAGView 如何配置能够保证被Dialog遮挡的时候动画也不要停止

原文地址: https://www.cveoy.top/t/topic/ianm 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录