简体   繁体   English

话语提示可访问性,要求将重点放在TextView上

[英]Talk Back accessibility, requesting focus on a TextView

We have a requirment for accessibility that when a given activity opens and the user has TalkBack accessibility on, the client wants the Talk Back to not just read the activity name, but also the text of our welcomeText TextView. 我们对可访问性有一个要求,即当给定活动打开并且用户启用了TalkBack可访问性时,客户端希望Talk Back不仅读取活动名称,而且还要读取我们的welcomeText TextView的文本。 That text view is dynamic in that it will say "Welcome, " 该文本视图是动态的,它会显示“ Welcome”

I tried doing this in the activity onCreate() by saying: 我尝试在活动onCreate()中这样做:

welcomeText =(TextView)getView().findViewById(R.id.authenticatedNoWishlistWelcomeText);

welcomeText.setFocusableInTouchMode(true);
welcomeText.requestFocus();

but this is not working.. can anyone tell me how i can get Talk Back to read a given TextView upon launch without the user interaction? 但这是行不通的。.有人能告诉我如何在启动时在不进行用户交互的情况下让“回话”读取给定的TextView吗?

The important thing to realize here, is that Focus and Accessibility Focus are not the same thing. 这里要意识到的重要一点是, FocusAccessibility Focus不是同一件事。

You are looking for the following: 您正在寻找以下内容:

welcomeText.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);

Be careful about when you do this. 请注意执行此操作的时间。 Doing this in onCreate is probably a bad idea, as then it will only happen when the application activity is loaded. 在onCreate中执行此操作可能不是一个好主意,因为只有在加载应用程序活动时才会发生。 What you probably want is for it to happen each time it is resumed. 您可能想要的是使其在每次恢复时都发生。 Also, the AT (TalkBack) creates its connection to the Activity at some point in this lifecycle, and so you want to be sure you don't have a race condition. 另外,AT(TalkBack)在此生命周期中的某个时刻创建与活动的连接,因此您要确保没有竞争条件。 TalkBack must connect to your activity before you post your Accessibility Event. 发布您的辅助功能事件之前,TalkBack必须连接到您的活动。

Though note, that this may be a bad requirement. 尽管注意,这可能是一个不好的要求。 WCag 3.2.1 and 3.2.3 clearly state that navigation should be consistent and predictable, and part of this is avoiding unexpected shifts of focus. WCag 3.2.1和3.2.3明确指出导航应该是一致且可预测的,并且部分是在避免意外的焦点转移。 This could be considered a violation of these guidelines, and actually less accessible than not doing so. 可以认为这违反了这些准则,并且实际上比没有准则容易获得。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM