全屏Dialog示例
2017-10-27 本文已影响28人
popli
final Dialog dialog = new Dialog(context,R.style.weighting_activity);
Window window = dialog.getWindow();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {// 在android4.4以上的手机,修改成沉寖式的样式
try {
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.requestFeature(Window.FEATURE_NO_TITLE);
/* set it to be full screen */
window.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
dialog.show();
Uri uri = Uri.parse("res:///" + R.drawable.virtual_create);
DraweeController controller = Fresco.newDraweeControllerBuilder().setUri(uri).setAutoPlayAnimations(true).build();
AbstractAnimatedDrawable animatable = (AbstractAnimatedDrawable) controller.getAnimatable();
android.view.WindowManager.LayoutParams attributes = window.getAttributes();
attributes.width = ViewGroup.LayoutParams.MATCH_PARENT;
attributes.height = ViewGroup.LayoutParams.MATCH_PARENT;
attributes.windowAnimations = 0;
window.setAttributes(attributes);
dialog.setContentView(R.layout.layout_virtualrole_gif);
SimpleDraweeView draweeView = (SimpleDraweeView) window.findViewById(R.id.body_trend);
draweeView.setController(controller);