GradientDrawable 可以用来通过程序方式给控件设置背景如圆角,边框等

来源:互联网 发布:centos7.0安装nginx 编辑:程序博客网 时间:2024/05/19 00:55
@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);}
0 0
原创粉丝点击