Skip to content

Commit

Permalink
兼容信的判断
Browse files Browse the repository at this point in the history
  • Loading branch information
maning committed Aug 24, 2017
1 parent 9b7f2ec commit 78555e5
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.os.Build;
import android.text.InputFilter;
import android.text.TextUtils;
import android.util.AttributeSet;
Expand Down Expand Up @@ -161,7 +162,13 @@ protected void onDraw(Canvas canvas) {
drawable.setStroke((int) borderWidth, borderColor);
drawable.setCornerRadius(borderRadius);
drawable.setColor(backgroundColor);
setBackground(drawable);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
//Android系统大于等于API16,使用setBackground
setBackground(drawable);
} else {
//Android系统小于API16,使用setBackgroundDrawable
setBackgroundDrawable(drawable);
}
float itemW = measuredWidth / maxLength;
//画线
for (int i = 1; i < maxLength; i++) {
Expand Down

0 comments on commit 78555e5

Please sign in to comment.