ScrollView disable focus move

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

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



        
10条回答
  •  醉梦人生
    2020-12-14 16:54

    I tried all solutions posted here but either didn't work on certain Android versions or it messed up with some other behavior like when switching between touch and non-touch mode (when you click buttons or use the trackpad).

    I finally found that overriding the method getFocusables did the trick:

    public class FixedFocusScrollView extends ScrollView {
    
      public FixedFocusScrollView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
      }
    
      public FixedFocusScrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
      }
    
      public FixedFocusScrollView(Context context) {
        super(context);
      }
    
      @Override
      public ArrayList getFocusables(int direction) {
        return new ArrayList();
      }
    
    }
    

提交回复
热议问题