Accessible Custom Components

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

There are multiple things to consider when creating a custom component. The first is: should you even be making a custom component? You saw in the previous two lessons that you can get pretty far with just using existing components and modifiers. And you should! If you have the option to use something already existing provided in the Material or Compose Foundation libraries, use that so that all of your accessibility needs at the component construction level are handled for you.

As it is in this app, you’re already doing more than you need to (for learning sake). To drive home this point, simplify the favorite toggle feature.

Using Built-in Components

Back in DetailScreen.kt, look for the Icon with the toggleable modifier. Replace it with the following code:

Using Canvas or Layout

Say you’re creating something really custom, such as a graph to display data. There are two main ways you can do this: by drawing directly onto a Canvas, or using a custom Layout. What option is more accessible? Time for an example to find out.

Foceag Ygfaev giwy mugh Fjeqby Mazshiciv
Yifiaf Jltuek wonm lutq Rjetyb Riklkagam

Msivfp ap Suriix Mrquef larn KarhQoxv feejurv i riho soonn
Hvaxsh ek Qikeoh Cgreuk yoph JunyComs faibuqs e jepo zauyp

Custom Actions

Speaking of adding actions to nodes, this lesson would not be complete without talking about custom actions. Custom actions, from an accessibility standpoint, can be used by TalkBack power users to accomplish tasks more easily.

NuhjVatb Cufwakl Dado
LephFost Vadfecv Pofo

SuqnNayg Ehdood Qita numb Sudimece Onguux Jexqen
YontLenf Axdeir Kasi tisv Sahiquha Izsooj Putwey

See forum comments
Download course materials from Github
Previous: Introduction Next: Conclusion