Comments (11)
可以自定义Style以修改动画效果,例如基于MaterialStyle的主题,进行如下修改(请参考注释)
public class CustomStyle implements DialogXStyle {
private CustomStyle() {
}
public static MaterialStyle style() {
return new CustomStyle();
}
@Override
public int layout(boolean light) {
return light ? com.kongzue.dialogx.R.layout.layout_dialogx_material : com.kongzue.dialogx.R.layout.layout_dialogx_material_dark;
}
@Override
public int enterAnimResId() {
//在这里修改你自定义的弹出对话框动画
return com.kongzue.dialogx.R.anim.anim_dialogx_default_enter;
}
@Override
public int exitAnimResId() {
//在这里修改你自定义的关闭对话框动画
return com.kongzue.dialogx.R.anim.anim_dialogx_default_exit;
}
@Override
public int[] verticalButtonOrder() {
return new int[]{BUTTON_OK, BUTTON_OTHER, BUTTON_CANCEL};
}
@Override
public int[] horizontalButtonOrder() {
return new int[]{BUTTON_OTHER, SPACE, BUTTON_CANCEL, BUTTON_OK};
}
@Override
public int splitWidthPx() {
return 1;
}
@Override
public int splitColorRes(boolean light) {
return 0;
}
@Override
public BlurBackgroundSetting messageDialogBlurSettings() {
return null;
}
@Override
public HorizontalButtonRes overrideHorizontalButtonRes() {
return new HorizontalButtonRes() {
@Override
public int overrideHorizontalOkButtonBackgroundRes(int visibleButtonCount, boolean light) {
return light ? com.kongzue.dialogx.R.drawable.button_dialogx_material_light : com.kongzue.dialogx.R.drawable.button_dialogx_material_night;
}
@Override
public int overrideHorizontalCancelButtonBackgroundRes(int visibleButtonCount, boolean light) {
return light ? com.kongzue.dialogx.R.drawable.button_dialogx_material_light : com.kongzue.dialogx.R.drawable.button_dialogx_material_night;
}
@Override
public int overrideHorizontalOtherButtonBackgroundRes(int visibleButtonCount, boolean light) {
return light ? com.kongzue.dialogx.R.drawable.button_dialogx_material_light : com.kongzue.dialogx.R.drawable.button_dialogx_material_night;
}
};
}
@Override
public VerticalButtonRes overrideVerticalButtonRes() {
return new VerticalButtonRes() {
@Override
public int overrideVerticalOkButtonBackgroundRes(int visibleButtonCount, boolean light) {
return light ? com.kongzue.dialogx.R.drawable.button_dialogx_material_light : com.kongzue.dialogx.R.drawable.button_dialogx_material_night;
}
@Override
public int overrideVerticalCancelButtonBackgroundRes(int visibleButtonCount, boolean light) {
return light ? com.kongzue.dialogx.R.drawable.button_dialogx_material_light : com.kongzue.dialogx.R.drawable.button_dialogx_material_night;
}
@Override
public int overrideVerticalOtherButtonBackgroundRes(int visibleButtonCount, boolean light) {
return light ? com.kongzue.dialogx.R.drawable.button_dialogx_material_light : com.kongzue.dialogx.R.drawable.button_dialogx_material_night;
}
};
}
@Override
public WaitTipRes overrideWaitTipRes() {
return new WaitTipRes() {
@Override
public boolean blurBackground() {
return false;
}
@Override
public int overrideBackgroundColorRes(boolean light) {
return 0;
}
@Override
public int overrideTextColorRes(boolean light) {
return light ? com.kongzue.dialogx.R.color.white : com.kongzue.dialogx.R.color.black;
}
@Override
public ProgressViewInterface overrideWaitView(Context context, boolean light) {
return new ProgressView(context);
}
};
}
@Override
public BottomDialogRes overrideBottomDialogRes() {
return new BottomDialogRes() {
@Override
public boolean touchSlide() {
return true;
}
@Override
public int overrideDialogLayout(boolean light) {
return light ? com.kongzue.dialogx.R.layout.layout_dialogx_bottom_material : com.kongzue.dialogx.R.layout.layout_dialogx_bottom_material_dark;
}
@Override
public int overrideMenuDividerDrawableRes(boolean light) {
return light ? com.kongzue.dialogx.R.drawable.rect_dialogx_material_menu_split_divider : com.kongzue.dialogx.R.drawable.rect_dialogx_material_menu_split_divider_night;
}
@Override
public int overrideMenuDividerHeight(boolean light) {
return 1;
}
@Override
public int overrideMenuTextColor(boolean light) {
return light ? com.kongzue.dialogx.R.color.black90 : com.kongzue.dialogx.R.color.white90;
}
@Override
public float overrideBottomDialogMaxHeight() {
return 0.6f;
}
@Override
public int overrideMenuItemLayout(boolean light, int index, int count, boolean isContentVisibility) {
return 0;
}
@Override
public int overrideSelectionMenuBackgroundColor(boolean light) {
return 0;
}
@Override
public boolean selectionImageTint(boolean light) {
return false;
}
@Override
public int overrideSelectionImage(boolean light, boolean isSelected) {
return isSelected ? com.kongzue.dialogx.R.mipmap.img_dialogx_bottom_menu_material_item_selection : com.kongzue.dialogx.R.mipmap.img_dialogx_bottom_menu_material_item_non_select;
}
};
}
@Override
public PopTipSettings popTipSettings() {
return new PopTipSettings() {
@Override
public int layout(boolean light) {
return light ? com.kongzue.dialogx.R.layout.layout_dialogx_poptip_material : com.kongzue.dialogx.R.layout.layout_dialogx_poptip_material_dark;
}
@Override
public ALIGN align() {
return ALIGN.BOTTOM;
}
@Override
public int enterAnimResId(boolean light) {
return com.kongzue.dialogx.R.anim.anim_dialogx_default_enter;
}
@Override
public int exitAnimResId(boolean light) {
return com.kongzue.dialogx.R.anim.anim_dialogx_default_exit;
}
};
}
}
其他主题请参考对应的开源代码进行修改,具体文档详见:https://github.com/kongzue/DialogX/wiki/%E8%87%AA%E5%AE%9A%E4%B9%89-DialogX-%E4%B8%BB%E9%A2%98
使用前请记得设置DialogX的主题为自定义主题:
DialogX.globalStyle = CustomStyle.style();
from dialogx.
动画效果没问题,很好,就是持续时间,我看源码是固定了300
from dialogx.
boxRoot.animate().setDuration(enterAnim.getDuration()).alpha(1f).setInterpolator(new DecelerateInterpolator()).setDuration(300).setListener(null);
boxRoot.animate().setDuration(300).alpha(0f).setInterpolator(new AccelerateInterpolator()).setDuration(enterAnim.getDuration()).setListener(new AnimatorListenerEndCallBack() {
@OverRide
public void onAnimationEnd(Animator animation) {
dismiss(dialogView);
}
});
我没看错的话应该是这两个地方控制的持续时间
from dialogx.
会考虑在之后的版本开放设置的
from dialogx.
谢谢
kotlin版本我加了这么个指令,可以在弹窗消失后执行指定操作,对于一些需要按步骤显示窗口的挺有用的
fun <T : CustomDialog> T.after(go: T.() -> Unit): CustomDialog {
this.dialogLifecycleCallback = object : DialogLifecycleCallback<CustomDialog>() {
override fun onDismiss(dialog: CustomDialog?) {
go()
}
}
return this
}
fun <T : MessageDialog> T.after(go: T.() -> Unit): MessageDialog {
this.dialogLifecycleCallback = object : DialogLifecycleCallback<MessageDialog>() {
override fun onDismiss(dialog: MessageDialog?) {
go()
}
}
return this
}
fun <T : InputDialog> T.after(go: T.() -> Unit): InputDialog {
this.dialogLifecycleCallback = object : DialogLifecycleCallback<MessageDialog>() {
override fun onDismiss(dialog: MessageDialog?) {
go()
}
}
return this
}
from dialogx.
请更新至0.0.29.alpha3版本,已经在DialogX类中加入了设置项:
//默认启动对话框动画时长
public static long enterAnimDuration = -1;
//默认关闭对话框动画时长
public static long exitAnimDuration = -1;
如果还需要更多设置可以继续留言。
from dialogx.
好的。谢谢。。。。
from dialogx.
另外预告下下一个正式版还会加入对应到每个Dialog的get/set方法
from dialogx.
很抱歉之前的版本可能存在部分对话框不生效的问题,您可以更新至 0.0.29.alpha4 版本,此版本以修复问题并提供了每个Dialog实例的动画时长 get/set 方法
from dialogx.
好的,谢谢。我测试下
from dialogx.
正常工作,谢谢
from dialogx.
Related Issues (20)
- 【BUG反馈】 getWindow().setBackgroundDrawableResource在DialogX的对话框消失后失效 HOT 6
- 【BUG反馈】 BottomMenu 点击其余背景地方弹框不会消失 HOT 5
- 【BUG反馈】 键盘部分遮挡 HOT 41
- 【功能建议】依赖的三方库使用固定版本号,避免使用“2.0.4+”这种动态依赖 HOT 1
- 一个空指针异常【BUG反馈】 HOT 2
- 【BUG反馈】 BottomDialog与 RecycleView滑动冲突问题 HOT 13
- 【BUG反馈】 0.0.49.beta13 开始 FullScreenDialog 设置 setMaxHeight 显示后位置异常,底部有多余边距 HOT 7
- 【BUG反馈】 DialogFragmentImpl没有默认的空参数构造方法,数据恢复时反射可能导致崩溃 HOT 2
- 【BUG反馈】 深色模式下,CookieBar 会闪退 HOT 2
- 【功能建议】请填写标题 HOT 3
- 合规性建议 HOT 2
- 【BUG反馈】FullScreenDialog 会被系统顶部状态栏遮盖 HOT 8
- 【BUG反馈】 HOT 2
- JitPack引用依赖下载失败 HOT 4
- 【功能建议】FullscreenDialog下潜背景R角 HOT 7
- 【功能建议】BottomDialog 增加默认动画监听 HOT 3
- 【BUG反馈】 PopMenu有内存泄漏 HOT 1
- 【BUG反馈】 神奇的闪退 HOT 2
- 【功能建议】希望TipDialog可以设置取消动画的方法 HOT 2
- 【BUG反馈】使用bottomDialog关闭时会出现滚动Recyclerview item情况 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dialogx.