Java 将编辑文本置于软键盘上方
我使用的是两个FrameLayout,其中都有EditText,如果我单击位于布局底部的编辑文本,可以在软键盘上方看到,但是如果我单击位于另一个frameLayout上方的编辑框,则frameLayout位置不会更改并放置在键盘后面,而位于底部的frameLayout再次更改其位置并显示在软键盘上方 我试过了Java 将编辑文本置于软键盘上方,java,android,android-layout,Java,Android,Android Layout,我使用的是两个FrameLayout,其中都有EditText,如果我单击位于布局底部的编辑文本,可以在软键盘上方看到,但是如果我单击位于另一个frameLayout上方的编辑框,则frameLayout位置不会更改并放置在键盘后面,而位于底部的frameLayout再次更改其位置并显示在软键盘上方 我试过了 mMessageBox.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override publ
mMessageBox.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
Commons.logCatchya("onFocusListener changed !");
if (hasFocus) {
Commons.logCatchya("onFocusListener hasFocus !");
}
else {
Commons.logCatchya("onFocusListener do not hav focus !");
}
}
});
mMessageBox.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
Commons.logCatchya("setOnKeyListener :" + event.getAction() + " keyCode :" + keyCode);
return false;
}
});
mProfileStatusBox.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
Commons.logCatchya("onFocusListener mProfileStatusBox changed !");
if (hasFocus) {
Commons.logCatchya("onFocusListener mProfileStatusBox hasFocus !");
}
else {
Commons.logCatchya("onFocusListener mProfileStatusBox do not hav focus !");
}
}
});
但如果我点击屏幕上的隐藏软键盘按钮,光标仍在我使用的编辑框中。这个问题是因为框架布局吗?İf不知道我应该做什么来解决这个问题。在活动中为活动标签设置此选项
android:configChanges="keyboardHidden|orientation"
如果对您不起作用,请尝试在ScrollView中设置父布局为活动中的活动标记设置此布局
android:configChanges="keyboardHidden|orientation"
如果它对您不起作用,请尝试在ScrollView中设置父布局我确信您正在使用
线性布局
将其宽度
和高度
设置为完整的父布局
。
不要这样做,使用
RelativeLayout
而不是将高度设置为:
android:layout\u height=“wrap\u content”
我确信您正在使用LinearLayout
将其宽度和高度设置为full\u parent
。
不要这样做,使用RelativeLayout
而不是将高度设置为:
android:layout\u height=“wrap\u content”
我通过使用RelativeLayout
和
android:gravity="bottom"
在布局文件中。我通过使用RelativeLayout
和
android:gravity="bottom"
在布局文件中