Stop Scrollview from Auto-Scrolling to an Edittext

How to disable default scroll behavior of an EditText?

Set your EditText's height to wrap_content so it expands instead of scrolling. Set your LinearLayout's height to wrap_content so it's the size of its contents, i.e. the TextView and EditText.

The ScrollView should be whatever height you want for your "window" into the contents layout, the LinearLayout that moves up and down "behind" the ScrollView.

The scrolling happens if that contents layout is too big to display in the visible ScrollView, which is why that contents layout should always be wrap_content (the size of the contents) and never match_parent (the size of the scroll view "window"). If the contents are always the same size as the scroll view, they'll never need to scroll, right?

Stop ScrollView from setting focus on EditText

This works. Not sure if it's the best solution or not.

// SCROLL VIEW HACK
// BOGUS
ScrollView view = (ScrollView)findViewById(R.id.scrollView);
view.setDescendantFocusability(ViewGroup.FOCUS_BEFORE_DESCENDANTS);
view.setFocusable(true);
view.setFocusableInTouchMode(true);
view.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
v.requestFocusFromTouch();
return false;
}
});

How to prevent auto scrolling of EditText when keyboard appears on Android?

Addthis

 android:windowSoftInputMode="adjustPan"

android:isScrollContainer="false"

in the manifest file

How to stop Scrollview from moving background image to top while pressing EditText?

Add this in Activity Manifest

android:windowSoftInputMode="adjustNothing"


Related Topics



Leave a reply



Submit