当 edittext
获得焦点时,我使用以下代码将页面滚动到底部:
fcListener = new OnFocusChangeListener() {
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus)
handler.postDelayed(new Runnable() {
@Override
public void run() {
Page.fullScroll(ScrollView.FOCUS_DOWN);
}
},300);
}
};
personNameText.setOnFocusChangeListener(fcListener);
但是,每当我单击 editText 时,它会在页面向下滚动后几乎没有获得焦点。然后 edittext 失去焦点。每次都会发生这种情况。如何防止失去焦点但仍使页面向下滚动?
最佳答案
不要尝试使用自定义代码进行滚动,而是在 Android Manifest.xml 中对 Activity 使用 android:windowSoftInputMode="adjustResize"。
关于android - 当编辑文本获得焦点时滚动页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13685389/