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
Android, How to Exec a SQL File in Sqlitedatabase
How to Create Listview Inside Dialog
How to Run Android Studio (Android Sdk Emulator) in a Microsoft Hyper-V Virtual Machine
How to Display a One Time Welcome Screen
Android: How to Download a Video File to Sd Card
Set View Text Align at Center in Spinner in Android
Install_Failed_Cpu_Abi_Incompatible on Device Using Intellij
Multiple Notifications to The Same Activity
Android: Tint Using Drawablecompat
Speechrecognizer Causes Anr... I Need Help with Android Speech API
Conversion from String to JSON Object Android
How to Load Image as Bitmap to Glide
Combining Two Bitmap Image (Side by Side)
How to Replace a String for a Buildvariant with Gradle in Android Studio
Android: Share Session Between Webview and Httpclient
How to Play .Mp4 Video in Videoview in Android
How to Import an Existing Project from Github into Android Studio