千家信息网

如何使用Android仿微信网络加载弹出框

发表于:2025-02-03 作者:千家信息网编辑
千家信息网最后更新 2025年02月03日,这篇文章给大家分享的是有关如何使用Android仿微信网络加载弹出框的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。1. 自定义view的style样式

2.dialog_custom_bg 加载动画shape背景图(drawable文件夹下)

3.indeterminate_drawable 进度条模糊背景图(drawable文件夹下)

4.加载对话框的背景

5.CustomDialog自定义控件

public class CustomDialog extends Dialog { private String content; public CustomDialog(Context context, String content) { super(context, R.style.CustomDialog); this.content=content; initView(); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { switch (keyCode){ case KeyEvent.KEYCODE_BACK: if(CustomDialog.this.isShowing()) CustomDialog.this.dismiss(); break; } return true; } private void initView(){ setContentView(R.layout.dialog_view); ((TextView)findViewById(R.id.tvcontent)).setText(content); setCanceledOnTouchOutside(true); WindowManager.LayoutParams attributes = getWindow().getAttributes(); attributes.alpha=0.8f; getWindow().setAttributes(attributes); setCancelable(false); }}

6.Activity中直接调用

CustomDialog customDialog = new CustomDialog(this, "正在加载...");customDialog.show();//显示,显示时页面不可点击,只能点击返回customDialog.dismiss();//消失

感谢各位的阅读!关于"如何使用Android仿微信网络加载弹出框"这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

0