문제

I have edittext for entering first name when creating account and its hint is "Jane"(as first name). I also want to have content description on this edittext for accessibility saying "first name". When I set both hint and content description warning pops up "Do not set both contentDescription and hint: the contentDescription will mask the hint" and this is fine, it's just that content description doesn't mask hint. When I turn on TalkBack it still reads hint and not content description.

Could anyone help me with this. Thnx.

도움이 되었습니까?

해결책

From what I understand, android:hint is meant as a placeholder for text in TextViews (and its subclasses) as long as they do not display any text, whereas android:contentDescription is meant as alternative textual description for non-textual content (images...). Therefore I'd set hint on the EditText only.

다른 팁

I encountered the same problem and solved it by setting the hint to null when the accessibility service is enabled. Cause when it is enabled the user probably won't need the hint.

private void setAccessibility()
{
   if (isExploreByTouchEnabled())
   {         
      firstName.setHint(null);
      firstName.setContentDescription("first name");
   }
}

public boolean isExploreByTouchEnabled()
{
   AccessibilityManager am = (AccessibilityManager) getContext().getSystemService(ACCESSIBILITY_SERVICE);
   boolean isAccessibilityEnabled = am.isEnabled();
   boolean isExploreByTouchEnabled = am.isTouchExplorationEnabled();
   return isAccessibilityEnabled && isExploreByTouchEnabled;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top