How to scroll the edittext inside the scrollview

前端 未结 12 1858
南笙
南笙 2020-12-02 10:27

I have a scrollview inside which there is a editext which is multiline. I want to scroll the edittext to see the lower content but it can\'t be done.

12条回答
  •  有刺的猬
    2020-12-02 11:15

    Try this..

    Add below lines into your EditText

    android:overScrollMode="always"
    android:scrollbarStyle="insideInset"
    android:scrollbars="vertical"
    

    Example

       
        
    

    EDIT

    Programmatically

    youredittext.setOnTouchListener(new OnTouchListener() {
    
          public boolean onTouch(View v, MotionEvent event) {
                if (youredittext.hasFocus()) {
                   v.getParent().requestDisallowInterceptTouchEvent(true);
                   switch (event.getAction() & MotionEvent.ACTION_MASK){
                   case MotionEvent.ACTION_SCROLL:
                          v.getParent().requestDisallowInterceptTouchEvent(false);
                          return true;
                    }
                 }
                 return false;
           }
    });
    

提交回复
热议问题