Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何修改圆角大小 #228

Closed
mxdlsm opened this issue Aug 9, 2022 · 11 comments
Closed

如何修改圆角大小 #228

mxdlsm opened this issue Aug 9, 2022 · 11 comments
Labels
新需求 新功能需求标记

Comments

@mxdlsm
Copy link

mxdlsm commented Aug 9, 2022

No description provided.

@mxdlsm mxdlsm added the 新需求 新功能需求标记 label Aug 9, 2022
@kongzue
Copy link
Owner

kongzue commented Aug 9, 2022

具体是指哪个组件呢?

@mxdlsm
Copy link
Author

mxdlsm commented Aug 9, 2022

MessageDialog

@kongzue
Copy link
Owner

kongzue commented Aug 9, 2022

Material主题么?

@mxdlsm
Copy link
Author

mxdlsm commented Aug 9, 2022

是的

@kongzue
Copy link
Owner

kongzue commented Aug 9, 2022

步骤一:
请在自己的 app/res/drawable 中新创建一个 xml 文件,命名为:rect_dialogx_material_bkg_light.xml,并在其中编写代码:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="@color/white"/>
    <corners android:radius="10dp" />
</shape>

步骤二:
请修改其中的 android:radius 属性值。

步骤三:
测试运行。

@kongzue
Copy link
Owner

kongzue commented Aug 9, 2022

对应的暗色对话框背景资源名是 button_dialogx_material_night.xml

@mxdlsm
Copy link
Author

mxdlsm commented Aug 9, 2022

这样一修改是不是所有的弹窗圆角都改变了?谢谢

@kongzue
Copy link
Owner

kongzue commented Aug 9, 2022

对,如果需要单独设置,请修改上述步骤一的资源名名称,修改为非 rect_dialogx_material_bkg_light.xml 的任意其他名称,然后使用:

.setDialogLifecycleCallback(new DialogLifecycleCallback<MessageDialog>() {
    @Override
    public void onShow(MessageDialog dialog) {
        super.onShow(dialog);
        dialog.getDialogImpl().bkg.setBackgroundResource(R.drawable.your_custom_bkg);
    }
})

对背景进行设置。

@kongzue
Copy link
Owner

kongzue commented Aug 9, 2022

另外一提,DialogX 的对话框内的组件全都是对外暴露的,但要进行操作,请确保在对话框实例创建后进行,例如 DialogLifecycleCallback#onShow 后进行修改

@mxdlsm
Copy link
Author

mxdlsm commented Aug 9, 2022

OK,谢谢啦

@mxdlsm mxdlsm closed this as completed Aug 9, 2022
@kongzue
Copy link
Owner

kongzue commented Aug 9, 2022

另外分享给你一则好消息,在下一个版本开始,将会对部分对话框增加 .setBackgroundRadius(float px) 设置以方便直接修改背景圆角,单位像素。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
新需求 新功能需求标记
Projects
None yet
Development

No branches or pull requests

2 participants