开发者

ScrollView steals focus when scrolling

开发者 https://www.devze.com 2023-04-06 11:12 出处:网络
I am trying to make a chatting window. There\'s a TextView wrapped in a ScrollView in the upper side of the screen; and a EditText in the bottom of the screen.

I am trying to make a chatting window. There's a TextView wrapped in a ScrollView in the upper side of the screen; and a EditText in the bottom of the screen. I use following code to make the ScrollView scroll automatically when the new message is out of view.

scroll.post(new Runnable(){
@Override
public void run() {
       scroll.fullScroll(View.FOCUS_DOWN);
}
});

Something annoying is when the ScrollView scrolls, it steals my focus from the EditText. I can't input my message when 开发者_开发技巧the ScrollView is scrolling. Can anybody give me some light? Thanks a lot : )


I know a workaround. Call requestFocus on the view that should keep the focus.

It would be nice to know if you solved it in a better way.

0

精彩评论

暂无评论...
验证码 换一张
取 消