Android Development: Improve EditText Scrolling?

自作多情 提交于 2019-11-27 22:22:38

问题


Is there any way I can increase my EditText's scrolling? I want to make it scroll like it does on the web browse, smooth and fast. Is this possible?

Thanks, Alex.


回答1:


Webview uses Smooth scrolling. A scroll view also have this property.

  • Add the text view inside a Scrollview.
  • Make an ID for the scrollview and create reference in your code.
  • Place the EditText Within this scroll view(Make the editText to Wrap Content).

Enable Smooth Scrolling using the below method,

public void setSmoothScrollingEnabled(boolean smoothScrollingEnabled)

Control the smooth scrolling by specifying bounds for the scroll, using the below method...

public final void smoothScrollBy (int dx, int dy)
//dx,dy.. offset (Relative Position)

public final void smoothScrollTo (int x, int y)
//scroll to x and y (actual position)

You can also imitate the overscroll behavior using the following Method,

public void setOverScrollMode (int mode)

Also you can add Fling Action using the following method,..

public void fling (int velocityY)



回答2:


A better description of the current and desired behaviour would be good, however you might get the desired behaviour by embedding in a ScrollView.




回答3:


You could create a CustomEditText extends EditText class and override the onTouch and onTouchEvent methods and use these to detect gestures and then move the contents up or down.



来源:https://stackoverflow.com/questions/4353792/android-development-improve-edittext-scrolling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!