diff options
Diffstat (limited to 'accessibility/CheckableLayout/template-params.xml')
-rw-r--r-- | accessibility/CheckableLayout/template-params.xml | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/accessibility/CheckableLayout/template-params.xml b/accessibility/CheckableLayout/template-params.xml new file mode 100644 index 00000000..e251ae03 --- /dev/null +++ b/accessibility/CheckableLayout/template-params.xml @@ -0,0 +1,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> |