Is there a way to programmatically scroll a scroll view to a specific edit text?
private final void focusOnView(){
your_scrollview.post(new Runnable() {
@Override
public void run() {
your_scrollview.scrollTo(0, your_EditBox.getBottom());
}
});
}
Android, How to Scroll Programmatically a scrollview When I Clicked on edittext
Thank you guys for all answers, but I solved my problem by myself,
First I would like to say you have to use "OnFocusListener" and then you have to use Handler like this;
Now, When I click my edittext; keyboard opened and scrollview scrolled to top at the same time :)
et_space.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus){
final Handler handler;
handler = new Handler();
final Runnable r = new Runnable() {
public void run() {
scrollView.smoothScrollTo(0, 500);
}
};
handler.postDelayed(r, 200);
}
}
});
Scroll a Scroll View which contains Edit Text
Both previously pointed out solutions can work. But there might still be a problem if the edittext is at the bottom of the ListView where it would still be covered by the onscreen keyboard. Not sure if a scrollview can be scrolled to a point where there is no more content.
What i've seen is that you might use two contradicting flags in your manifest:
android:windowSoftInputMode="stateHidden|adjustResize|adjustPan" > </activity>
adjustResize and adjustPan can imho NOT be combined. Try how it looks with only adjustResize. This should avoid that the keyboard covers anything of your view.
Can I scroll a ScrollView programmatically in Android?
ScrollView sv = (ScrollView)findViewById(R.id.scrl);
sv.scrollTo(0, sv.getBottom());
or
sv.scrollTo(5, 10);
How to scroll the edittext inside the scrollview
Try this..
Add below lines into your EditText
android:overScrollMode="always"
android:scrollbarStyle="insideInset"
android:scrollbars="vertical"
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>
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;
}
});
Related Topics
Android: How to Create a Dialog Without a Title
Recyclerview - How to Smooth Scroll to Top of Item on a Certain Position
Android Fragment Lifecycle Over Orientation Changes
Read the Package Name of an Android APK
Timepicker in Preferencescreen
Android Hide/Unhide App Icon Programmatically
Programmatically Update Widget from Activity/Service/Receiver
Android Image View Pinch Zooming
How to Detect the Swipe Left or Right in Android
Full Webpage and Disabled Zoom Viewport Meta Tag for All Mobile Browsers
Android Lollipop, Appcompat Actionbar Custom View Doesn't Take Up Whole Screen Width
How to Add a Library (Android-Support-V7-Appcompat) in Intellij Idea
Get JSONarray Without Array Name