Skip to content

Commit 4e0cebc

Browse files
author
张家伟
committed
fix:[修复bug:设置上下左右边框时,会有多余的空格]
描述:{ 分析:在setLayerInset时,如果是需要显示的边框,也设置了指定的宽度,导致那个方位多了一个width的空白 方案:在setLayerInset时,如果是需要显示的边框,应该设置为0 }
1 parent 391a1e6 commit 4e0cebc

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

library/src/main/java/com/noober/background/BackgroundFactory.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,10 @@ private static void setBackground(Drawable drawable, View view, TypedArray typed
293293
int bottom = 1 << 4;
294294
float width = typedArray.getDimension(R.styleable.background_bl_stroke_width, 0f);
295295
int position = typedArray.getInt(R.styleable.background_bl_stroke_position, 0);
296-
float leftValue = hasStatus(position, left) ? width : -width;
297-
float topValue = hasStatus(position, top) ? width : -width;
298-
float rightValue = hasStatus(position, right) ? width : -width;
299-
float bottomValue = hasStatus(position, bottom) ? width : -width;
296+
float leftValue = hasStatus(position, left) ? 0 : -width;
297+
float topValue = hasStatus(position, top) ? 0 : -width;
298+
float rightValue = hasStatus(position, right) ? 0 : -width;
299+
float bottomValue = hasStatus(position, bottom) ? 0 : -width;
300300
drawable = new LayerDrawable(new Drawable[]{drawable});
301301
((LayerDrawable) drawable).setLayerInset(0, (int) leftValue, (int) topValue, (int) rightValue, (int) bottomValue);
302302
}

libraryx/src/main/java/com/noober/background/BackgroundFactory.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,10 @@ private static void setBackground(Drawable drawable, View view, TypedArray typed
296296
int bottom = 1 << 4;
297297
float width = typedArray.getDimension(R.styleable.background_bl_stroke_width, 0f);
298298
int position = typedArray.getInt(R.styleable.background_bl_stroke_position, 0);
299-
float leftValue = hasStatus(position, left) ? width : -width;
300-
float topValue = hasStatus(position, top) ? width : -width;
301-
float rightValue = hasStatus(position, right) ? width : -width;
302-
float bottomValue = hasStatus(position, bottom) ? width : -width;
299+
float leftValue = hasStatus(position, left) ? 0 : -width;
300+
float topValue = hasStatus(position, top) ? 0 : -width;
301+
float rightValue = hasStatus(position, right) ? 0 : -width;
302+
float bottomValue = hasStatus(position, bottom) ? 0 : -width;
303303
drawable = new LayerDrawable(new Drawable[]{drawable});
304304
((LayerDrawable) drawable).setLayerInset(0, (int) leftValue, (int) topValue, (int) rightValue, (int) bottomValue);
305305
}

0 commit comments

Comments
 (0)