-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rounded Views with borders shows small gap
Summary: When a __rounded__ View on Android has a border, a small gap appears between the border and the center of the view (most noticeably when the background and border colors are the same) Since the border is drawn on top of the other layers, the approach here is to make the center of the View slightly larger so that there is an overlap with the border, and closing the visible gap There are 2 cases for a View with a border: 1. `borderWidth` is set for a consistent border width around all 4 edges 2. Uneven border widths are set (using `borderTopWidth`, `borderLeftWidth, ...) **How is a rounded rectangle drawn?** __Case 1__: `borderWidth` is set for a consistent border width around all 4 edges - Before: - first, `mInnerClipPathForBorderRadius` was used to draw the center of the View - then the border is drawn along the path of `mCenterDraw` with a stroke width of the border width - Now: - `mBackgroundColorRenderPath` is used to draw the center of the View and is exactly a slightly enlarged version of `mInnerClipPathForBorderRadius` __Case 2__: Uneven border widths are set (using borderTopWidth, borderLeftWidth, ...) - Before: - `mInnerClipPathForBorderRadius` was used to draw the center of the View - for each edge, a quadrilateral is drawn - `mOuterClipPathForBorderRadius` clips the outer edge of the border - `mInnerClipPathForBorderRadius` (same is used to draw the center of the View) clips the inner edge of the border - Now: - `mBackgroundColorRenderPath` is used to draw the center of the View, allowing `mInnerClipPathForBorderRadius` to persist as the path that clips the inner edge of the border When `mGapBetweenPaths` = 0, `mBackgroundColorRenderPath` == `mInnerClipPathForBorderRadius`, which is exactly the original implementation Changelog: [Internal][Fixed] - rounded Views with borders shows small gap Reviewed By: mdvacca Differential Revision: D39979567 fbshipit-source-id: 6db71d14ead6256e1b7becf73862e0a537c6a47b
- Loading branch information
1 parent
6743d15
commit 29caed2
Showing
2 changed files
with
65 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters