5

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?

ankitjainb27
  • 51
  • 1
  • 3
  • 1
    What do you mean by "using Accessibility"? – Doug Stevenson Feb 11 '16 at 07:13
  • 1
    Accessibility is a feature in android used mainly for making apps for specially abled people. See this link - http://developer.android.com/guide/topics/ui/accessibility/index.html – ankitjainb27 Feb 11 '16 at 11:08
  • What's your goal. Unfortunately neither of these pieces of information are exposed to the accessibility apis, but if you tell me your goal, I may be able to provide a good alternate solution... – MobA11y Feb 11 '16 at 14:53

2 Answers2

2

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 :)

MobA11y
  • 18,425
  • 3
  • 49
  • 76
-2

For text size of the textview you can provide size in terms of 'sp' instead of 'dp'. Framework will automatically take care of size.

And for color above answer given by @rakesh can be one of the answers.

samsap
  • 60
  • 2
  • 7