Android TalkBack reading phone numbers in Webview incorrectly

こ雲淡風輕ζ 提交于 2020-01-05 05:26:08

问题


I'm having a minor headache with the TalkBack screen reader service when reading phone numbers in a WebView, and I can't seem to find a solution. This is a snippet of some html code that I am reading into the WebView:

<li>Call <a href="tel:18007848669">1-800-QUIT-NOW(1-800-784-8669)</a> for phone support</li>

The screen reader reads this as "Call one to eight hundred quit now one to eight hundred link". Is there a way to force it/signal to read it differently? I need it to be read in a more natural format, i.e. "One Eight Hundred".


回答1:


For this element, android:contentDescription="One eight hundred quit now"




回答2:


Use the following Accessibility Deligate for your editText or textView

@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(host, info);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {

        switch (host.getId()) {
            case R.id.tv_bookingID:
                if (((TextView) host).getText().length() > 1) {
                    sb.delete(0, sb.length());
                    for (char c : ((TextView) host).getText().toString().toCharArray()) {
                        sb.append(c).append(" ");
                    }
                    //change text for talkback
                    info.setText(null);
                    info.setContentDescription(sb.toString().trim());

                }
                break;
        }//switch
    }//if
}


来源:https://stackoverflow.com/questions/15371057/android-talkback-reading-phone-numbers-in-webview-incorrectly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!