@SuppressLint("NewApi") public void setPopupStyle(final int backgroundColor, final int borderColor, final int borderWidthDP, float cornerRadiusDP, final int textColor) { final GradientDrawable popupbackground = new GradientDrawable(); popupbackground.setCornerRadius(cornerRadiusDP * density); popupbackground.setStroke((int) (borderWidthDP * density), borderColor); popupbackground.setColor(backgroundColor); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) scrollIndicatorTextView.setBackgroundDrawable(popupbackground); else scrollIndicatorTextView.setBackground(popupbackground); scrollIndicatorTextView.setTextColor(textColor); }
GradientDrawable 可以用来通过程序方式给控件设置背景如圆角,边框等
最新推荐文章于 2025-05-19 20:50:59 发布
本文介绍了一种自定义Popup样式的方法,通过设置背景颜色、边框颜色、边框宽度及圆角等属性,实现对Popup视图外观的定制。适用于Android应用开发中需要个性化提示框的场景。

319

被折叠的 条评论
为什么被折叠?



