Error Scroll EditText ScrollView (ESES)


ESES:   SOLD       




Hi dev, are you experiencing the same problem? That is when your EditText input type is multiline but the vertical scrollbars feature does not work when used inside the ScrollView component. Okay, actually it is not 100% impossible, but intermittent or sometimes happens.

Okay, regardless of whether it only happens occasionally or often, it clearly has a negative impact on user experience, so I tried to use my Google Fu to find a suitable solution for this problem.

Because normally when EditText is clicked it gets focus along with the cursor and of course the vertical scrollbar if the character exceeds the limits of the specified EditText field.

Just to give you an idea, it looks more or less like this.

Okay, after surfing quite a bit, I finally found the solution, which is by adding some attributes to the EditText component, like this.

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

Implementation example.

   <EditText
        android:id="@+id/editText1"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:layout_marginTop="15dp"
        android:background="#eeeeee"
        android:inputType="textMultiLine"
        android:singleLine="false"
        android:overScrollMode="always"
        android:scrollbarStyle="insideInset"
        android:scrollbars="vertical"
        android:text="Android applications normally run entirely on a single thread by              default the “UI thread” or the “main thread”.
        android:textAppearance="?android:attr/textAppearanceMedium" >
    </EditText>

You can also do it programmatically, like this.

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;
       }
});

Done!


Post a Comment

Previous Next

نموذج الاتصال