Android NestedScrollView TalkBack - 仅导航到屏幕上可见的项目,跳过滚动条下方的元素并直接到达底部选项卡。
创始人
2024-08-14 20:30:09
0

要实现Android NestedScrollView中TalkBack只导航到屏幕上可见的项目,并跳过滚动条下方的元素直接到达底部选项卡,可以使用以下方法:

  1. 在XML布局文件中,将NestedScrollView包裹在AccessibilityDelegateCompat中,并设置AccessibilityDelegateCompat类的实例作为NestedScrollView的AccessibilityDelegate。


    


  1. 在Java代码中,为NestedScrollView创建AccessibilityDelegateCompat类的实例,并覆盖其performAccessibilityAction()方法。在该方法中,根据要求导航到屏幕上可见的项目,并跳过滚动条下方的元素直接到达底部选项卡。
import androidx.core.view.AccessibilityDelegateCompat;
import androidx.core.view.ViewCompat;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import androidx.core.widget.NestedScrollView;

public class CustomAccessibilityDelegate extends AccessibilityDelegateCompat {

    @Override
    public boolean performAccessibilityAction(View host, int action, Bundle args) {
        if (action == AccessibilityNodeInfoCompat.ACTION_SCROLL_FORWARD) {
            NestedScrollView nestedScrollView = (NestedScrollView) host;
            int visibleChildCount = nestedScrollView.getChildCount();

            if (visibleChildCount > 0) {
                View lastVisibleChild = nestedScrollView.getChildAt(visibleChildCount - 1);

                if (lastVisibleChild != null) {
                    ViewCompat.AccessibilityDelegateCompat.super.performAccessibilityAction(lastVisibleChild, action, args);
                    return true;
                }
            }
        }

        return ViewCompat.AccessibilityDelegateCompat.super.performAccessibilityAction(host, action, args);
    }
}
  1. 将创建的AccessibilityDelegateCompat实例设置为NestedScrollView的AccessibilityDelegate。
NestedScrollView nestedScrollView = findViewById(R.id.nestedScrollView);
CustomAccessibilityDelegate accessibilityDelegate = new CustomAccessibilityDelegate();
ViewCompat.setAccessibilityDelegate(nestedScrollView, accessibilityDelegate);

通过以上步骤,TalkBack将只导航到屏幕上可见的项目,并跳过滚动条下方的元素直接到达底部选项卡。请根据自己的需求进行适当调整和修改。

相关内容

热门资讯

开挂透视!wepoker辅助插... 无需打开直接搜索;操作使用教程:开挂透视!wepoker辅助插件怎么用,wepoker发牌规律总结,...
辅助工具!wepoker透视辅... 您好:wepoker透视辅助器最新版本更新内容这款游戏可以开挂的,确实是有挂的,很多玩家在这款游戏中...
开挂透视!wpk透视挂免费测试... 您好,微扑克辅助器免费最新版本更新内容这款游戏可以开挂的,确实是有挂的,需要了解加微【1367043...
开挂辅助工具!wpk德州最新版... 开挂辅助工具!wpk德州最新版,wepoker透视挂方法,(科技分享外挂辅助挂)是一款可以让一直输的...
开挂透视!wepoker开挂辅... 开挂透视!wepoker开挂辅助挂,wepoker辅助透视挂,(玩家科普外挂辅助挂)是一款可以让一直...
透视脚本!WePoker玩家总... 无需打开直接搜索加微信客服(136704302)咨询了解微扑克封号如何避免辅助器目前(微信:1367...
脚本辅助!wepoker好友局... wepoker好友局能不能透视是一款可以让一直输的玩家,快速成为一个“必胜”的ai辅助神器,有需要的...
透视辅助!微扑克辅助工具免费版... >>您好:微扑克辅助工具免费版苹果软件加扣扣群确实是有挂的,很多玩家在这款游戏中打牌都会发现很多用户...
开挂透视!wepoker规律总... 开挂透视!wepoker规律总结,微乐扑克辅助器免费版,(揭秘外挂辅助平台)是一款可以让一直输的玩家...
开挂辅助工具!wpk透视插件怎... 您好:wepoker辅助挂怎么用最安全这款游戏是可以开挂的,软件加【添加微信客服136704302】...