牙叔教程 简单易懂
对话框
定义
对话框是提示用户做出决定或输入更多信息的小窗口。对话框不会占据整个屏幕,通常适用于需要用户进行操作才能继续执行的模态框事件。
Site Unreachable
子类
样式
基础对话框
alert("牙叔教程");
修改背景色
importClass(android.graphics.drawable.GradientDrawable); let view = ui.inflate(<text>牙叔教程</text>, null, false); let dialog = dialogs.build({ customView: view, }); let dialogWindow = dialog.getWindow(); setBackgroundPureColour(dialogWindow); dialog.show(); function setBackgroundPureColour(view) { let gradientDrawable = new GradientDrawable(); gradientDrawable.setColor(colors.parseColor("#c8e6c9")); view.setBackgroundDrawable(gradientDrawable); }
修改圆角
importClass(android.graphics.drawable.GradientDrawable); let view = ui.inflate(<text>牙叔教程</text>, null, false); let dialog = dialogs.build({ customView: view, }); let dialogWindow = dialog.getWindow(); setBackgroundRoundRounded(dialogWindow); dialog.show(); function setBackgroundRoundRounded(view) { let gradientDrawable = new GradientDrawable(); gradientDrawable.setShape(GradientDrawable.RECTANGLE); gradientDrawable.setColor(colors.parseColor("#c8e6c9")); gradientDrawable.setCornerRadius(60); view.setBackgroundDrawable(gradientDrawable); }
调整背景透明度
let view = ui.inflate(<text>牙叔教程</text>, null, false); let dialog = dialogs.build({ customView: view, }); let dialogWindow = dialog.getWindow(); dialogWindow.setDimAmount(0.9); dialog.show();
自定义布局
"ui"; importClass(Packages.androidx.appcompat.app.AlertDialog); let view = ui.inflate(<text>牙叔教程</text>, null, false); var builder = new AlertDialog.Builder(activity); builder.setView(view); var dialog = builder.create(); dialog.show();
自定义布局2
"ui"; importClass(Packages.androidx.appcompat.app.AlertDialog); let view = ui.inflate(<text>牙叔教程</text>); var builder = new AlertDialog.Builder(activity); var dialog = builder.create(); dialog.setView(view); dialog.show();
环境
手机: Mi 11 Pro
Android版本: 12
Autojs版本: 9.1.0
相关文章
名人名言
思路是最重要的, 其他的百度, bing, stackoverflow, github, 安卓文档, autojs文档, 最后才是群里问问
--- 牙叔教程
声明
部分内容来自网络
本教程仅用于学习, 禁止用于其他用途