Skip to content

Commit

Permalink
fix:[修复bug:设置上下左右边框时,会有多余的空格]
Browse files Browse the repository at this point in the history
描述:{
分析:在setLayerInset时,如果是需要显示的边框,也设置了指定的宽度,导致那个方位多了一个width的空白
方案:在setLayerInset时,如果是需要显示的边框,应该设置为0
}
  • Loading branch information
张家伟 committed Sep 3, 2021
1 parent 391a1e6 commit 4e0cebc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,10 @@ private static void setBackground(Drawable drawable, View view, TypedArray typed
int bottom = 1 << 4;
float width = typedArray.getDimension(R.styleable.background_bl_stroke_width, 0f);
int position = typedArray.getInt(R.styleable.background_bl_stroke_position, 0);
float leftValue = hasStatus(position, left) ? width : -width;
float topValue = hasStatus(position, top) ? width : -width;
float rightValue = hasStatus(position, right) ? width : -width;
float bottomValue = hasStatus(position, bottom) ? width : -width;
float leftValue = hasStatus(position, left) ? 0 : -width;
float topValue = hasStatus(position, top) ? 0 : -width;
float rightValue = hasStatus(position, right) ? 0 : -width;
float bottomValue = hasStatus(position, bottom) ? 0 : -width;
drawable = new LayerDrawable(new Drawable[]{drawable});
((LayerDrawable) drawable).setLayerInset(0, (int) leftValue, (int) topValue, (int) rightValue, (int) bottomValue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,10 @@ private static void setBackground(Drawable drawable, View view, TypedArray typed
int bottom = 1 << 4;
float width = typedArray.getDimension(R.styleable.background_bl_stroke_width, 0f);
int position = typedArray.getInt(R.styleable.background_bl_stroke_position, 0);
float leftValue = hasStatus(position, left) ? width : -width;
float topValue = hasStatus(position, top) ? width : -width;
float rightValue = hasStatus(position, right) ? width : -width;
float bottomValue = hasStatus(position, bottom) ? width : -width;
float leftValue = hasStatus(position, left) ? 0 : -width;
float topValue = hasStatus(position, top) ? 0 : -width;
float rightValue = hasStatus(position, right) ? 0 : -width;
float bottomValue = hasStatus(position, bottom) ? 0 : -width;
drawable = new LayerDrawable(new Drawable[]{drawable});
((LayerDrawable) drawable).setLayerInset(0, (int) leftValue, (int) topValue, (int) rightValue, (int) bottomValue);
}
Expand Down

0 comments on commit 4e0cebc

Please sign in to comment.