图例:

代码

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 布局

<?xml version="1.0" encoding="utf-8"?>                                                                                        

3、style.xml 样式布局:指定dialog内容样式

<?xml version="1.0" encoding="utf-8"?>    

 

更多相关文章

  1. android 自定义对话框 背景透明
  2. ExpandableListView设置选中child的背景
  3. android上多样式文本的使用
  4. Android(安卓)Jetpack Compose 之 Text
  5. Android(安卓)tab 背景及字体颜色设置
  6. android评分条RatingBar自定义设置
  7. Android(安卓)编程下背景图片适配工具类
  8. Android(安卓)Jetpack Compose 之 Text
  9. Android(安卓)设置View背景图网络url

随机推荐

  1. android jar转dex
  2. 2.Android开发---xml布局文件中的常见属
  3. Android动画效果 translate、scale、alph
  4. Android studio嵌入二维码扫描
  5. Android(安卓)图像缩略图及压缩图像
  6. 安卓ListView和CheckBox组合使用
  7. [4.18]Android生命周期介绍
  8. 关于自定义布局,xml中配置属性(attrs)
  9. (一)Android背景知识
  10. Android 图形学原理之OpenGL ES