【开源】BlurDialogFragment
BlurDialogFragment
- https://github.com/tvbarthel/BlurDialogFragment
介绍:
可以在dialog的后面造成模糊效果,模糊的实现是基于FastBlur算法实现的。运行效果:
![]()
使用说明:
最简单的使用方式是继承BlurDialogFragment或者SupportBlurDialogFragment。
如果你用的是android.app.DialogFragment,那么继承BlurDialogFragment
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
/** * Simple fragment with blurring effect behind. */public class SampleDialogFragment extends BlurDialogFragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.debug(true); this.setBlurRadius(4); this.setDownScaleFactor(5.0f); ... } ...} |
如果是android.support.v4.app.DialogFragment 则继承 SupportBlurDialogFragment
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
/** * Simple fragment with blurring effect behind. */public class SampleDialogFragment extends SupportBlurDialogFragment { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.debug(true); this.setBlurRadius(4); this.setDownScaleFactor(5.0f); ... } ...} |
如果你不想使用继承的方式可以直接使用BlurEngine自定义一个DialogFragment
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/** * Your blur fragment directly using BlurEngine. */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.debug(mDebugEnable); mBlurEngine.setBlurRadius(8); mBlurEngine.setDownScaleFactor(8f); } @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.onDestroy(); } @Override public void onDestroyView() { if (getDialog() != null) { getDialog().setDismissMessage(null); } super.onDestroyView(); } ...} |
posted on 2015-04-09 09:42 wasdchenhao 阅读(214) 评论(0) 收藏 举报

浙公网安备 33010602011771号