• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

.google/23-Mar-2024-1812

Application/23-Mar-2024-1,701731

gradle/wrapper/23-Mar-2024-66

screenshots/23-Mar-2024-

CONTRIB.mdD23-Mar-20241.6 KiB3627

CONTRIBUTING.mdD23-Mar-20241.5 KiB3627

LICENSED23-Mar-202411.1 KiB204170

README.mdD23-Mar-20243.2 KiB9669

build.gradleD23-Mar-202414 150

gradlewD23-Mar-20245 KiB165122

gradlew.batD23-Mar-20242.3 KiB9166

packaging.yamlD23-Mar-2024474 1610

settings.gradleD23-Mar-202422 21

README.md

1
2Android ClippingBasic Sample
3===================================
4
5A basic app showing how to clip on a View using [ViewOutlineProvider][1] interface,
6by which a View builds its outline, used for shadowing and clipping.
7
8Introduction
9------------
10
11The [ViewOutlineProvider][1] interface offers you a method to populate the outline of a View.
12You need to implement a getOutline(android.view.View, android.graphics.Outline)
13method to clip a View in a specific shape.
14
15This example clips the outline of a View as a rounded rectangle by defining a class that
16 implements ViewOutlineProvider by following code:
17
18```java
19private class ClipOutlineProvider extends ViewOutlineProvider {
20    @Override
21    public void getOutline(View view, Outline outline) {
22        final int margin = Math.min(view.getWidth(), view.getHeight()) / 10;
23        outline.setRoundRect(margin, margin, view.getWidth() - margin,
24                view.getHeight() - margin, margin / 2);
25    }
26}
27```
28
29To clip a View by the defined outline, setting a OutlineProvider to a View
30to be clipped is needed like following:
31
32```java
33final View clippedView = view.findViewById(R.id.frame);
34clippedView.setOutlineProvider(mOutlineProvider);
35```
36
37You can toggle if the View is clipped by calling [setClipToOutline(boolean)][2]
38like following code:
39
40```java
41clippedView.setClipToOutline(true); // Setting false disable clipping
42```
43
44[1]: https://developer.android.com/reference/android/view/ViewOutlineProvider.html
45[2]: https://developer.android.com/reference/android/view/View.html#setClipToOutline(boolean)
46
47Pre-requisites
48--------------
49
50- Android SDK 27
51- Android Build Tools v27.0.2
52- Android Support Repository
53
54Screenshots
55-------------
56
57<img src="screenshots/screenshot-1.png" height="400" alt="Screenshot"/> <img src="screenshots/screenshot-2.png" height="400" alt="Screenshot"/>
58
59Getting Started
60---------------
61
62This sample uses the Gradle build system. To build this project, use the
63"gradlew build" command or use "Import Project" in Android Studio.
64
65Support
66-------
67
68- Google+ Community: https://plus.google.com/communities/105153134372062985968
69- Stack Overflow: http://stackoverflow.com/questions/tagged/android
70
71If you've found an error in this sample, please file an issue:
72https://github.com/googlesamples/android-ClippingBasic
73
74Patches are encouraged, and may be submitted by forking this project and
75submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details.
76
77License
78-------
79
80Copyright 2017 The Android Open Source Project, Inc.
81
82Licensed to the Apache Software Foundation (ASF) under one or more contributor
83license agreements.  See the NOTICE file distributed with this work for
84additional information regarding copyright ownership.  The ASF licenses this
85file to you under the Apache License, Version 2.0 (the "License"); you may not
86use this file except in compliance with the License.  You may obtain a copy of
87the License at
88
89http://www.apache.org/licenses/LICENSE-2.0
90
91Unless required by applicable law or agreed to in writing, software
92distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
93WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
94License for the specific language governing permissions and limitations under
95the License.
96