Why does my android activity always start scrolled to the bottom?

前端 未结 11 924
萌比男神i
萌比男神i 2020-12-22 20:56

Whenever I start this activity, it always starts bottomed out--scrolled all the way to the bottom. I am not doing anything weird in the activity OnCreate (or anywhere for th

11条回答
  •  一个人的身影
    2020-12-22 21:11

    Along with what devmiles.com said.

    If you set the following property in your LinearLayout - android:focusableInTouchMode="true" your LinearLayout will be focused on start and your activity won't scroll to EditText in the bottom.

    If you call requestLayout() on a view at the bottom of your linear layout it might steal the focus from your top most view. So just call requestFocus() on the top most view in the linear layout after calling requestLayout() on a lower view.

提交回复
热议问题