Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I get and set textcolor of a textView using Accessibility in Android

I am developing an app for color-blind, I want to know if I can change the textcolor of a textView using Accessibility in Android. Also, I would like to change the textSize using Accessibility.

Can I do these things?, If yes, how?

like image 258
ankitjainb27 Avatar asked Nov 20 '22 15:11

ankitjainb27


1 Answers

No, you cannot. You don't get the actual TextView of the represented text. You get access to an AccessibilityNodeInfo. The accessibility APIs don't provide this information. You could do some hacky things if you also controlled the app content, but if you want something that will work universally over all applications, you simply can't do this.

You could guess at the size of the text by checking the size of the TextView. The size of the TextView is passed to you through

aNodeInfo.getBoundsInScreen(resultBounds);

Although, this is very hacky and not reliable. The size of the view and the text size don't have to be the same, or even remotely related. Though generally for single line TextViews there will be a tight correlation. Notably, you cannot detect when a TextView is single line :)

like image 197
ChrisCM Avatar answered Dec 09 '22 17:12

ChrisCM