gpt4 book ai didi

android - TabBar 使用自定义 EditText 与软键盘一起向上移动

转载 作者:行者123 更新时间:2023-11-30 02:56:01 25 4
gpt4 key购买 nike

我正在使用自定义 EditText 来保存多行文本,并在软键盘中使用“发送”选项。它工作正常,但我的标签栏与键盘一起移动到顶部。我在 list 文件中使用了以下内容。

    android:windowSoftInputMode="adjustPan"
android:windowSoftInputMode="adjustResize"

这些对于普通的 EditText 工作正常。但是失败了,如果我使用的是 CustomEditText。

这是我的 xml:

 <com.sample.helpers.CustomEditText 
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:hint="Description"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textSize="16dp"
android:id="@+id/et_description"

/>

我的自定义 EditText 类:

public class CustomEditText extends EditText {



public CustomEditText(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}

public CustomEditText(Context context) {
super(context);
// TODO Auto-generated constructor stub
}

public CustomEditText(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
}

@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
InputConnection connection = super.onCreateInputConnection(outAttrs);
int imeActions = outAttrs.imeOptions&EditorInfo.IME_MASK_ACTION;
if ((imeActions&EditorInfo.IME_ACTION_NEXT) != 0) {
// clear the existing action
outAttrs.imeOptions ^= imeActions;
// set the DONE action
outAttrs.imeOptions |= EditorInfo.IME_ACTION_NEXT;
}
if ((outAttrs.imeOptions&EditorInfo.IME_FLAG_NO_ENTER_ACTION) != 0) {
outAttrs.imeOptions &= ~EditorInfo.IME_FLAG_NO_ENTER_ACTION;
}
return connection;
}

}

屏幕截图:

enter image description here

所以,请指导我如何处理这个问题。

最佳答案

在您的 Java 代码中试试这个

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

关于android - TabBar 使用自定义 EditText 与软键盘一起向上移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23249249/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com