-
Notifications
You must be signed in to change notification settings - Fork 3k
PictureSelector 2.0 自定义动态主题(包含裁剪、相册启动动画) Code方式
Luck edited this page Jan 9, 2022
·
1 revision
// 相册主题
PictureParameterStyle mPictureParameterStyle = new PictureParameterStyle();
// 是否改变状态栏字体颜色(黑白切换)
mPictureParameterStyle.isChangeStatusBarFontColor = false;
// 是否开启右下角已完成(0/9)风格
mPictureParameterStyle.isOpenCompletedNumStyle = false;
// 是否开启类似QQ相册带数字选择风格
mPictureParameterStyle.isOpenCheckNumStyle = false;
// 相册状态栏背景色
mPictureParameterStyle.pictureStatusBarColor = Color.parseColor("#393a3e");
// 相册列表标题栏背景色
mPictureParameterStyle.pictureTitleBarBackgroundColor = Color.parseColor("#393a3e");
// 相册列表标题栏右侧上拉箭头
mPictureParameterStyle.pictureTitleUpResId = R.drawable.picture_icon_arrow_up;
// 相册列表标题栏右侧下拉箭头
mPictureParameterStyle.pictureTitleDownResId = R.drawable.picture_icon_arrow_down;
// 相册文件夹列表选中圆点
mPictureParameterStyle.pictureFolderCheckedDotStyle = R.drawable.picture_orange_oval;
// 相册返回箭头
mPictureParameterStyle.pictureLeftBackIcon = R.drawable.picture_icon_back;
// 标题栏字体颜色
mPictureParameterStyle.pictureTitleTextColor = ContextCompat.getColor(this, R.color.picture_color_white);
// 相册右侧取消按钮字体颜色
mPictureParameterStyle.pictureCancelTextColor = ContextCompat.getColor(this, R.color.picture_color_white);
// 相册列表勾选图片样式
mPictureParameterStyle.pictureCheckedStyle = R.drawable.picture_checkbox_selector;
// 选择相册目录背景样式
mPictureParameterStyle.pictureAlbumStyle = R.drawable.picture_new_item_select_bg;
// 相册列表底部背景色
mPictureParameterStyle.pictureBottomBgColor = ContextCompat.getColor(this, R.color.picture_color_fa);
// 已选数量圆点背景样式
mPictureParameterStyle.pictureCheckNumBgStyle = R.drawable.picture_num_oval;
// 相册列表底下预览文字色值(预览按钮可点击时的色值)
mPictureParameterStyle.picturePreviewTextColor = ContextCompat.getColor(this, R.color.picture_color_fa632d);
// 相册列表底下不可预览文字色值(预览按钮不可点击时的色值)
mPictureParameterStyle.pictureUnPreviewTextColor = ContextCompat.getColor(this, R.color.picture_color_9b);
// 相册列表已完成色值(已完成 可点击色值)
mPictureParameterStyle.pictureCompleteTextColor = ContextCompat.getColor(this, R.color.picture_color_fa632d);
// 相册列表未完成色值(请选择 不可点击色值)
mPictureParameterStyle.pictureUnCompleteTextColor = ContextCompat.getColor(this, R.color.picture_color_9b);
// 预览界面底部背景色
mPictureParameterStyle.picturePreviewBottomBgColor = ContextCompat.getColor(this, R.color.picture_color_grey_3e);
// 外部预览界面删除按钮样式
mPictureParameterStyle.pictureExternalPreviewDeleteStyle = R.drawable.picture_icon_delete;
// 外部预览界面是否显示删除按钮
mPictureParameterStyle.pictureExternalPreviewGonePreviewDelete = true;
// 相册右侧按钮背景样式,只针对isWeChatStyle 为true时有效果
mPictureParameterStyle.pictureUnCompleteBackgroundStyle = R.drawable.picture_send_button_default_bg;
// 相册右侧按钮可点击背景样式,只针对isWeChatStyle 为true时有效果
mPictureParameterStyle.pictureCompleteBackgroundStyle = R.drawable.picture_send_button_bg;
// 以下设置如果用不上则不要设置,使用默认即可
// 自定义相册右侧文本内容设置
mPictureParameterStyle.pictureRightDefaultText = "";
// 自定义相册未完成文本内容
mPictureParameterStyle.pictureUnCompleteText = "";
// 完成文案是否采用(%1$d/%2$d)的字符串,只允许两个占位符哟
mPictureParameterStyle.isCompleteReplaceNum = true;
// 自定义相册完成文本内容
mPictureParameterStyle.pictureCompleteText = "";
// 自定义相册列表不可预览文字
mPictureParameterStyle.pictureUnPreviewText = "";
// 自定义相册列表预览文字
mPictureParameterStyle.picturePreviewText = "";
// 自定义相册标题字体大小
mPictureParameterStyle.pictureTitleTextSize = 18;
// 自定义相册右侧文字大小
mPictureParameterStyle.pictureRightTextSize = 14;
// 自定义相册预览文字大小
mPictureParameterStyle.picturePreviewTextSize = 14;
// 自定义相册完成文字大小
mPictureParameterStyle.pictureCompleteTextSize = 14;
// 自定义原图文字大小
mPictureParameterStyle.pictureOriginalTextSize = 14;
// 裁剪主题
PictureCropParameterStyle mCropParameterStyle = new PictureCropParameterStyle(
ContextCompat.getColor(MainActivity.this, R.color.app_color_grey),
ContextCompat.getColor(MainActivity.this, R.color.app_color_grey),
ContextCompat.getColor(MainActivity.this, R.color.app_color_white),
mPictureParameterStyle.isChangeStatusBarFontColor);
// 相册启动退出动画
PictureWindowAnimationStyle windowAnimationStyle = new PictureWindowAnimationStyle();
windowAnimationStyle.ofAllAnimation(R.anim.picture_anim_up_in, R.anim.picture_anim_down_out);
最后一定要在调起PictureSelector时进行如下设置(如果不需要设置的则可以不用设置,使用默认配制即可):
.setPictureStyle(mPictureParameterStyle); // 动态自定义相册主题
.setPictureCropStyle(mCropParameterStyle); // 动态自定义裁剪主题
.setPictureWindowAnimationStyle(windowAnimationStyle); // 自定义相册启动退出动画