ScrollView disable focus move

后端 未结 10 672
野性不改
野性不改 2020-12-14 16:36

I have a simple input form; it\'s a vertical LinearLayout with EditTexts inside a ScrollView.



        
10条回答
  •  -上瘾入骨i
    2020-12-14 17:01

    I have had such a problem too. The only way that helped me is to extend scroll view and to override neigher

    @Override
    public ArrayList getFocusables(int direction) {
        return new ArrayList();
    }
    

    or

    @Override
    protected boolean onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect) {
        return true;
    }
    

    but to override ViewGroup.requestChildFocus(View child, View focused) method as following:

        @Override
        public void requestChildFocus(View child, View focused) {
            // avoid scrolling to focused view
            // super.requestChildFocus(child, focused);
        }
    

提交回复
热议问题