Skip to content

Commit c9e87e8

Browse files
committed
fix: android support for clipToBounds
It comes with a major refactoring of the BorderDrawable. Now all Paths are cached not to regenerate them on every draw pass. Also it is important to understand that the clipping feature on android comes at a cost. It will be done only when truelly necessary. but with complex paths ((border radius > 0 && border non uniform) || border-width >0) then we must apply a costly drawing pass (though hardware accelerated) to accomplish it.
1 parent 00b0794 commit c9e87e8

4 files changed

Lines changed: 517 additions & 253 deletions

File tree

packages/core/ui/layouts/layout-base.android.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,8 @@ export class LayoutBase extends LayoutBaseCommon {
99
return true;
1010
}
1111
[clipToBoundsProperty.setNative](value: boolean) {
12-
// TODO: Use ClipRectangle if API > 16!
13-
14-
// We can't implement this without calling setClipChildren(false) on every ancestor up in the visual tree,
15-
// which will kill performance. It will also lead to unwanted side effects such as other totally unrelated
16-
// views being affected by setting the parents' setClipChildren to false.
17-
// The problem in Android is that a ViewGroup either clips ALL of its children or it does not. Unlike iOS, the clipping
18-
// cannot be controlled on a per view basis. So clipToBounds=false will have to be somehow achieved with stacking different
19-
// views on top of one another in an AbsoluteLayout or GridLayout. There is always a workaround when playing with layouts.
20-
//
21-
// The following article explains this in detail:
22-
// http://stackoverflow.com/questions/25044085/when-drawing-outside-the-view-clip-bounds-with-android-how-do-i-prevent-underli
23-
console.warn(`clipToBounds with value false is not supported on Android. You can use this.android.getParent().setClipChildren(false) as an alternative`);
12+
(<any>this.nativeViewProtected).setClipToBounds(value);
13+
2414
}
2515

2616
[isPassThroughParentEnabledProperty.setNative](value: boolean) {

packages/ui-mobile-base/android/widgets/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@ def computeTargetSdkVersion() {
5151
}
5252
}
5353

54+
5455
android {
56+
compileOptions {
57+
sourceCompatibility JavaVersion.VERSION_1_8
58+
targetCompatibility JavaVersion.VERSION_1_8
59+
}
5560
compileSdkVersion computeCompileSdkVersion()
5661
buildToolsVersion computeBuildToolsVersion()
5762

0 commit comments

Comments
 (0)