Android-----自定义AlertDialogd框

Android-----自定义AlertDialogd框,第1张

概述需要使用d框来实现加载效果,用的是别人的加载框架:repositories{google()jcenter()maven{url'https://jitpack.io'}}compile'com.github.zzz40500:android-shapeLoadingView:1.0.3.2'//内容加载展示(图形)自定义AlertDialogd框布

需要使用d框来实现加载效果,用的是别人的加载框架:

repositorIEs {        Google()        jcenter()        maven { url 'https://jitpack.io' }     }compile 'com.github.zzz40500:androID-shapeLoadingVIEw:1.0.3.2'  //内容加载展示(图形)

自定义AlertDialogd框布局:

<?xml version="1.0" enCoding="utf-8"?><!--    数据加载中提示布局    --><linearLayout    xmlns:androID="http://schemas.androID.com/apk/res/androID"    xmlns:app="http://schemas.androID.com/apk/res-auto"    xmlns:tools="http://schemas.androID.com/tools"    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content"    androID:orIEntation="vertical"    androID:gravity="center"    androID:background="@drawable/dialog_background_dark"    tools:context="com.org.huanjianmvp.Activity.ListDatas">    <com.mingle.Widget.LoadingVIEw        androID:ID="@+ID/loadVIEw"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"/></linearLayout>

 

写一个静态方法来返回自定义好的d框:

 

/**【加载框展示】**/    public static AlertDialog AlertLoading(Context context){        AlertDialog.Builder builder = new AlertDialog.Builder(context);        AlertDialog dialog = builder.create();        VIEw dialogVIEw = VIEw.inflate(context, R.layout.loading,null);   //自定义d框视图        LoadingVIEw loadingVIEw = dialogVIEw.findVIEwByID(R.ID.loadVIEw);        loadingVIEw.setLoadingText("数据加载中. . .");        dialog.setVIEw(dialogVIEw);        dialog.getwindow().setDimAmount(0f);    //去掉遮罩层        Window window = dialog.getwindow();        WindowManager.LayoutParams layout = window.getAttributes();        layout.Alpha = 0.5f;        window.setAttributes(layout);       //d窗透明度设置        dialog.setCancelable(false);        //点击d框无法取消        return dialog;    }

 

使用:

AlertDialog dialog= AlertDialogUtils.AlertLoading(Login.this);dialog.show();    //展示dialog.dismiss();//关闭

效果:

总结

以上是内存溢出为你收集整理的Android-----自定义AlertDialogd框全部内容,希望文章能够帮你解决Android-----自定义AlertDialogd框所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1060182.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存