android 自定义透明 等待 dialog,Android自定义Dialog内部透明、外部遮罩效果
Android自定义Dialog内部透明、外部遮罩效果
发布时间:2020-09-09 03:01:41
来源:脚本之家
阅读:117
作者:zst1303939801
本文实例为大家分享了Android自定义Dialog遮罩效果的具体代码,供大家参考,具体内容如下
图例:
代码
1、自定义dialog:引入样式和代码指定样式
package com.gxjl.pe.gxjlpesdk.view;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
import com.gxjl.pe.gxjlpesdk.R;
/**
* 相机、相册选择 弹框
* Created by xiaoshuai on 2018/8/20.
*/
public abstract class CameraPhotoDialog extends Dialog implements View.OnClickListener{
private Context context;
public CameraPhotoDialog(@NonNull Context context) {
super(context, R.style.dialogTransparent);//内容样式在这里引入
this.context = context;
}
public CameraPhotoDialog(@NonNull Context context, int themeResId) {
super(context, themeResId);
}
protected CameraPhotoDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
super(context, cancelable, cancelListener);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dialog_camrea_photo);
//tv_title = findViewById(R.id.tv_title);
Window dialogWindow = getWindow();
WindowManager.LayoutParams lp = dialogWindow.getAttributes();
DisplayMetrics d = context.getResources().getDisplayMetrics(); // 获取屏幕宽、高用
lp.width = (int) (d.widthPixels * 0.9); // 宽度设置为屏幕宽度的80%
//lp.dimAmount=0.0f;//外围遮罩透明度0.0f-1.0f
dialogWindow.setAttributes(lp);
dialogWindow.setGravity(Gravity.BOTTOM);//内围区域底部显示
}
@Override
public void onClick(View view) {
int i = view.getId();
if (i == R.id.tv_cancel) {
this.dismiss();
}
}
protected abstract void confirm();
}
2、dialog_camrea_photo.xml 布局
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:orientation="vertical">
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:background="@android:color/transparent"
android:orientation="vertical">
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_camera_check"
android:orientation="vertical">
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="15dp"
android:layout_gravity="center_horizontal"
android:text="拍照"
android:textSize="16sp"
android:textColor="@color/font_007AFF"/>
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/line_ECECED"/>
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="15dp"
android:layout_gravity="center_horizontal"
android:text="照片图库"
android:textSize="16sp"
android:textColor="@color/font_007AFF"/>
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@drawable/bg_camera_check"
android:orientation="vertical">
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="15dp"
android:layout_gravity="center_horizontal"
android:text="拍照"
android:textSize="16sp"
android:textColor="@color/font_007AFF"/>
3、style.xml 样式布局:指定dialog内容样式
@null
true
true
true
@android:color/transparent
@android:color/transparent
true
0.6
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持亿速云。
android 自定义透明 等待 dialog,Android自定义Dialog内部透明、外部遮罩效果相关推荐
- android 图片圆角 遮罩_Android 自定义View练手Demo(一)实现圆角遮罩效果
Android 自定义View系列文章 Android自定义View实现圆角遮罩效果 一图胜千言,有一个遮罩就会凸显出重点区域 1-1.jpg 本文通过两种方式来实现这种效果,来达到自定义View练手 ...
- Android - 自定义Dialog内部透明,外部有遮罩
图例: 代码 1.自定义dialog:引入样式和代码指定样式 package com.gxjl.pe.gxjlpesdk.view;import android.app.Dialog; import ...
- android 获取对话框对象,Android 基本Dialog和自定义Dialog
Android 基本Dialog和自定义Dialog Dialog类是对话框的基类,但你应该避免直接实例化Dialog ,可以使用子类 1.AlertDialog 此对话框可以显示标题,最多三个按钮, ...
- android如何自定义dialog,Android—自定义Dialog
在 Android 日常的开发中,Dialog 使用是比较广泛的.无论是提示一个提示语,还是确认信息,还是有一定交互的(弹出验证码,输入账号密码登录等等)对话框. 而我们去看一下原生的对话框,虽然随着 ...
- android 自定义带输入框的dialog,Android 基本Dialog和自定义Dialog
Android 基本Dialog和自定义Dialog Dialog类是对话框的基类,但你应该避免直接实例化Dialog ,可以使用子类 1.AlertDialog 此对话框可以显示标题,最多三个按钮, ...
- Android 几种弹框样式 自定义Dialog PopupWindow的使用
1.弹框的波浪线是动态的 和小度弹框样式相似 用到PopWindow 和自定义View . 2.这个弹框是动态的 用于网络加载时候 用到自定义Dialog 3.这就是一简单通用的弹框样式 第一种弹框 ...
- android activity传值到dialog,android 自定义AlertDialog 与Activity相互传递数据
**主要实现功能:** 1.从Activity的TextView中获取字符串设置到AlertDialog的TextView和EditText中 2.将AlertDialog的EditText中的值设置 ...
- Android 对话框(Dialog) 及 自定义Dialog
Activities提供了一种方便管理的创建.保存.回复的对话框机制,例如 onCreateDialog(int), onPrepareDialog(int, Dialog), showDialog( ...
- Android自定义半透明背景弹窗非popwindow/dialog超简单任意编写!
前日,一个朋友问我有没有好看的弹窗,功能不需要太难,说了一点需求,图: 然后我就写了个Demo给他. Activity的弹窗各种各样.很早就有,但是有的太过于单调,样式也不好看,有的自定义起来非常繁琐 ...
最新文章
- 【脑电信号分类】脑电信号提取PSD功率谱密度特征
- Linux启动加载过程解析
- linux系统编程之进程(七):system()函数使用
- line-height 属性
- springboot整合Mybatis提示org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- Intel 64/x86_64/IA-32/x86处理器 - SIMD指令集 - MMX技术(2) - 数据转换指令
- 单纯型法Ⅱ(bzoj 1061: [Noi2008]志愿者招募)
- Http第三方接口实现/异步Http请求
- android 管理fragment,在 Fragment 之间传递数据
- txt格式单词导入有道词典生词本
- 50本财富书籍进行收藏
- java 红牛摩托车_2017红牛世界五大越野摩托车系列耐力赛
- Android:修改电池容量
- 电路模型和电路定律(Ⅲ)
- RedHat and Oracle 离线安装oracle教程
- Python爬虫之知乎采集工具
- 学习软件工程导论的心得体会
- 全球及中国医用管材行业需求调研与竞争趋势研究报告2022版
- [图文]诗圣,诗仙,诗魔的风流事迹
- 山东大学数字图像处理实验(五)
热门文章
- RabbitMQ 下载、安装、配置、验证_rpm版本(Linux环境)
- VSFTPD Centos 7.6 _配置篇
- cropper基本用法
- vue中更换标签页.ico图标报错路径找不到图片
- mysql字段分隔符拆分_面试题Mysql数据库优化之垂直分表
- java maven导入导出_Java +EasyUI+SpringMvc实现Excle导入导出(上)
- C语言 数组排序 – 快速法排序 - C语言零基础入门教程
- php文件上传详解,PHP文件上传实例详解!!!
- 宝塔php安装那个合_使用宝塔面板安装nextcloud | 启用本地存储 | 安装smbclient
- mysql自增字段_MySQL自增字段的常用语句