aboutsummaryrefslogtreecommitdiff
path: root/accessibility/CheckableLayout/template-params.xml
blob: e251ae03e837d31dec9f308394c56a616a75ddbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?xml version="1.0" encoding="UTF-8"?>
<!--
 Copyright 2013 The Android Open Source Project

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->

<sample>
    <name>CheckableLayout</name>
    <group>Accessibility</group>
    <package>com.example.android.checkablelayout</package>
    <minSdk>16</minSdk>
    <strings>
        <intro>
            <![CDATA[
            Sample showing how to make an accessible custom view that extends
            a layout.
            ]]>
        </intro>
    </strings>

    <template src="base-build" />

    <metadata>
        <status>PUBLISHED</status>
        <categories>Accessibility</categories>
        <technologies>Android</technologies>
        <languages>Java</languages>
        <solutions>Mobile</solutions>
        <level>BEGINNER</level>
        <icon>screenshots/icon-web.png</icon>
        <screenshots>
            <img>screenshots/discover.png</img>
            <img>screenshots/checked.png</img>
        </screenshots>
        <api_refs>
            <android>android.view.accessibility.AccessibilityNodeInfo</android>
            <android>android.view.accessibility.AccessibilityEvent</android>
        </api_refs>
        <description>
            Sample demonstrating how to make a simple custom view accessible.
            Creates a simple `CheckableFrameLayout` that has the accessibility
            profile of builtin that implements the `Checkable` interface (e.g.
            `Checkbox`).
        </description>
        <intro>
          This sample implements a single custom view, a
          `CheckableFrameLayout`, which implements the `Checkable` interface
          and maintains a checked state.

          This sample uses the custom view as a container for two overlayed
          `<![CDATA[<ImageView>]]>`s. The first `<![CDATA[<ImageView>]]>` is
          always displayed, while the second `<![CDATA[<ImageView>]]>`'s
          display status toggles with the checked state of it's parent (the
          `CheckableLayout`). This second `<![CDATA[<ImageView>]]>` uses
          `android:duplicateParentState` (see `activity_main.xml`) and a
          drawable that is tied to `android:state_checked` (see
          `drawable/ic_checkable_item.xml`). This drawable is displayed only
          when the parent is in a checked state.

          This sample provides a basic introduction to Android accessibility
          by showing how to make a custom view behave similar to a builtin
          widget like a `Checkbox`.
          Developers should focus on two methods that are overridden from the
          parent class:
          `onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info)` and
          `onInitializeAccessibilityEvent(AccessibilityEvent event)`.

          The `onInitializeAccessibilityNodeInfo()` method provides
          accessibility services with information about the state of this
          view. We override this method to tell an accessibility service that
          this view is checkable, and we set the intitial checked state of the
          view.

          The `onInitializeAccessibilityEvent()` method is use by the
          system to obtain additional information about the state of the view
          as its state changes.

          With this information, an accessibility service has what it needs to
          allow a user to meaningfully discover the view and know its state.
        </intro>
    </metadata>
</sample>