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

SmartToast.classic()设置白色背景色无效 #45

Open
RookieKing15 opened this issue Apr 7, 2021 · 5 comments
Open

SmartToast.classic()设置白色背景色无效 #45

RookieKing15 opened this issue Apr 7, 2021 · 5 comments

Comments

@RookieKing15
Copy link

SmartToast.classic()
.config()
//设置背景颜色
.backgroundDrawableResource(R.drawable.rect_cornor6_solid_ffffff) 设置的是纯白色,但是弹窗出来是黑色背景

@vincent-series
Copy link
Owner

你好,你用的什么版本?另外最后有没有调用apply生效?config配置仅单次有效。其他地方使用不调用Config方法的话,都是默认配置。

@RookieKing15
Copy link
Author

你好,版本是3.1.5.
/**
* @param text 需要显示的文本
*/
public static void showLong(CharSequence text) {
getToastApi().showLongInCenter(text);
}

/**
 * 设置toast的样式
 */
private static PlainToastApi getToastApi() {
    return SmartToast.classic()
            .config()
            //设置背景颜色
            .backgroundDrawableResource(R.drawable.rect_cornor6_solid_ffffff)
            .backgroundColorResource(R.color.cffffff)

// //设置文本大小,单位sp,默认14sp
// .msgSize(18)
// //设置文本为粗体,默认false
// .msgBold(false)
//设置文本颜色,默认为白色
.msgColorResource(R.color.cffffff)
// //设置icon
// .iconResource(R.drawable.toast_icon)
// //设置icon大小,不设置则为原始大小
// .iconSizeDp(30)
// //设置icon位置,默认为文本左边,可设置为文本右边
// .iconPosition(ClassicToast.Config.ICON_POSITION_RIGHT)
// //icon与文本的间距,默认10dp
// .iconPaddingDp(12)
//设置当前页面退出时,新进入的页面不会依旧显示还未消失的Toast,默认false
.cancelOnActivityExit(true)
.apply();
}

@RookieKing15
Copy link
Author

还有报空指针的 Attempt to invoke virtual method 'int android.widget.Toast.getGravity()' on a null object reference

@RookieKing15
Copy link
Author

空指针的 5.0到10.0都有出现

@vincent-series
Copy link
Owner

问题已解决,请使用最新版。 @RookieKing15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants