范植勝
范植勝

Reputation: 807

How can I scroll item to middle of screen in scrollView when I press them

My project need to insert lots of data,I use scrollview to put them in one page.

Now I want it can scroll the item I press(primary Edittext) to the middle of screen.

I tried to use onFocusChangeListener()+scrollTo() with edittexts,but doesn't work very well.

Is there any better way to do it?

I want to make it act like this

Upvotes: 0

Views: 769

Answers (1)

ilovepjs
ilovepjs

Reputation: 622

Have an onTouchListener for the scrollview.

When the user touches the screen, grab the x and y coordinates and then simply scroll to that point. So scrollview.scrollTo(x,y).

See here for more info

Upvotes: 3

Related Questions