@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 可以用来通过程序方式给控件设置背景如圆角,边框等
最新推荐文章于 2024-04-23 16:24:13 发布