我有一个愚蠢的问题,请按照下面的图片
当我点击 Enter Email 时,它如下图所示,
现在,尽管使用了 android:windowSoftInputMode="adjustPan" android Lollipop 主题和工具栏,问题还是来了,
- 图片变小了。
- 电子邮件编辑文本应该显示在键盘上方,但实际上没有。
提出一些解决方案。
最佳答案
首先确保您在 xml 布局中提供了一个 ScrollView
。
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
...
...
</ScrollView>
然后在你的 activity
中确保你正在做这样的事情(这段代码只是为了演示在哪里使用 getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
) :
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.temp);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
final EditText time = (EditText)findViewById(R.id.timeET);
time.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
time.requestLayout();
MyActivity.this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_UNSPECIFIED);
return false;
}
});
final EditText date = (EditText)findViewById(R.id.dateET);
date.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
date.requestLayout();
MyActivity.this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_UNSPECIFIED);
return false;
}
});
}
关于android:windowSoftInputMode ="adjustPan"不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27854029/