如何模糊按钮点击事件的当前视图并在该模糊视图上设置图像?

时间:2017-04-17 10:32:34

标签: android android-layout android-studio imageview

我想做点像

this

我已经尝试过渲染脚本来实现这一目标。虽然我无法做到这一点。 我想通过单击编辑按钮在背景视图上获得此模糊效果。 请帮帮我。

1 个答案:

答案 0 :(得分:0)

看看这里! https://github.com/tvbarthel/BlurDialogFragment

添加gradle依赖

compile 'fr.tvbarthel.blurdialogfragment:lib:2.2.0'

创建自己的对话框

public class SampleDialogFragment extends MyCustomDialogFragment {

     /**
     * Engine used to blur.
     */
    private BlurDialogEngine mBlurEngine;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mBlurEngine = new BlurDialogEngine(getActivity());
        mBlurEngine.setBlurRadius(8);
        mBlurEngine.setDownScaleFactor(8f);
        mBlurEngine.debug(true);
        mBlurEngine.setBlurActionBar(true);
        mBlurEngine.setUseRenderScript(true);
    }

    @Override
    public void onResume() {
        super.onResume();
        mBlurEngine.onResume(getRetainInstance());
    }

     @Override
    public void onDismiss(DialogInterface dialog) {
        super.onDismiss(dialog);
        mBlurEngine.onDismiss();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        mBlurEngine.onDetach();
    }

    @Override
    public void onDestroyView() {
        if (getDialog() != null) {
            getDialog().setDismissMessage(null);
        }
        super.onDestroyView();
    }

    ...
}