Skip to content

Commit

Permalink
修复issues#109#111
Browse files Browse the repository at this point in the history
  • Loading branch information
lihangleo2 committed Aug 31, 2021
1 parent 4aa060d commit f6feeae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
9 changes: 6 additions & 3 deletions app/src/main/res/layout/activity_shape.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
app:hl_cornerRadius="10dp"
app:hl_strokeColor="#000"
app:hl_strokeColor="#E1E1E1"
app:hl_strokeWith="1px"
>


Expand All @@ -112,9 +113,11 @@
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
app:hl_cornerRadius="30dp"
app:hl_strokeColor="#E1E1E1"
app:hl_strokeWith="2px"
app:hl_cornerRadius_leftTop="0dp"
app:hl_cornerRadius_rightBottom="0dp"
app:hl_strokeColor="#000">
>

<TextView
android:layout_width="wrap_content"
Expand All @@ -135,7 +138,7 @@
app:hl_cornerRadius="30dp"
app:hl_cornerRadius_leftTop="0dp"
app:hl_cornerRadius_rightBottom="0dp"
app:hl_strokeColor="#000"
app:hl_strokeColor="#2196F3"
app:hl_strokeColor_true="#ff0000"
>

Expand Down
15 changes: 2 additions & 13 deletions shadowLibrary/src/main/java/com/lihang/ShadowLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -1055,13 +1055,8 @@ protected void onDraw(Canvas canvas) {
canvas.drawRoundRect(rectf, trueHeight / 2, trueHeight / 2, paint);
//解决边框线太洗时,四角的width偏大和其他边不同为什大姨夫啊被烦死了
if (stroke_color != -101) {
int the_height = (int) (rectf.bottom - rectf.top);
int the_height_stoke = (int) (rectf.bottom - stroke_with / 2 - rectf.top - stroke_with / 2);
int trueCorner = (int) (trueHeight * the_height_stoke / 2 / the_height);

RectF rectFStroke = new RectF(rectf.left + stroke_with / 2, rectf.top + stroke_with / 2, rectf.right - stroke_with / 2, rectf.bottom - stroke_with / 2);
canvas.drawRoundRect(rectFStroke, trueCorner, trueCorner, paint_stroke);

canvas.drawRoundRect(rectFStroke, trueHeight / 2-stroke_with / 2, trueHeight / 2-stroke_with / 2, paint_stroke);
}
}
} else {
Expand All @@ -1078,14 +1073,8 @@ protected void onDraw(Canvas canvas) {

canvas.drawRoundRect(rectf, mCornerRadius, mCornerRadius, paint);
if (stroke_color != -101) {
int the_height = (int) (rectf.bottom - rectf.top);
int the_height_stoke = (int) (rectf.bottom - stroke_with / 2 - rectf.top - stroke_with / 2);
int trueCorner = (int) (mCornerRadius * the_height_stoke / the_height);


RectF rectFStroke = new RectF(rectf.left + stroke_with / 2, rectf.top + stroke_with / 2, rectf.right - stroke_with / 2, rectf.bottom - stroke_with / 2);
canvas.drawRoundRect(rectFStroke, trueCorner, trueCorner, paint_stroke);

canvas.drawRoundRect(rectFStroke, mCornerRadius-stroke_with / 2, mCornerRadius-stroke_with / 2, paint_stroke);
}

}
Expand Down

0 comments on commit f6feeae

Please sign in to comment.