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?
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 :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With