Android edittext具有多行和adjustPan WindowsOfInputMode
在我目前正在使用的聊天应用程序中,我有一个底部的编辑文本栏,这是我的编辑文本布局:Android edittext具有多行和adjustPan WindowsOfInputMode,android,multiline,window-soft-input-mode,adjustpan,Android,Multiline,Window Soft Input Mode,Adjustpan,在我目前正在使用的聊天应用程序中,我有一个底部的编辑文本栏,这是我的编辑文本布局: <RelativeLayout android:id="@+id/bottom_bar" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" > <EditText and
<RelativeLayout
android:id="@+id/bottom_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
>
<EditText
android:id="@+id/edt_send_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_gravity="center_vertical"
android:layout_marginStart="12dip"
android:layout_toEndOf="@+id/img_add"
android:layout_toStartOf="@+id/img_send_message"
android:background="#00000000"
android:hint="@string/send_message"
android:inputType="textCapSentences|textMultiLine|textAutoComplete|textAutoCorrect"
android:isScrollContainer="false"
android:lineSpacingMultiplier="1.2"
android:maxHeight="120dip"
android:minHeight="45dip"
android:paddingBottom="19dip"
android:paddingTop="19dip"
android:scrollbars="none"
android:textColorHint="@color/colorPrimary"
android:textSize="16sp">
</EditText>
<!-- OTHER STUFF -->
</RelativeLayout>
当我开始打字时,多行很好
但当我将焦点移到第一行时,会发生这种情况,部分编辑文本会移到键盘下方
我知道使用adjustResize可以做到这一点,但我不能使用它,因为我有一个位图,它会被压缩。所以我不能使用调整大小
需要帮助,提前谢谢 有趣的问题,我唯一想到的就是这个老套的解决方案。此外,我不确定200毫秒是否足以满足较慢设备的需要。但也许它会帮助你
final EditText txtEdit = (EditText) findViewById(R.id.edt_send_message);
txtEdit.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View view)
{
final int sel = txtEdit.getSelectionStart();
txtEdit.setSelection(txtEdit.getText().length());
txtEdit.postDelayed(new Runnable() {
@Override
public void run() {
txtEdit.setSelection(sel);
}
}, 200);
}
});
我想你可以在答案中找到你的答案,但作为一个普通法,我复制了这个解决方案,这样我的答案就不会只指向一个链接
<!-- Dummy item to prevent AutoCompleteTextView from receiving focus -->
<LinearLayout
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width="0px"
android:layout_height="0px"/>
<!-- :nextFocusUp and :nextFocusLeft have been set to the id of this component
to prevent the dummy from receiving focus again -->
<AutoCompleteTextView android:id="@+id/autotext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:nextFocusUp="@id/autotext"
android:nextFocusLeft="@id/autotext"/>
如果不成功,请告诉我。您是否尝试过将属性android:scaleType=“fitCenter”添加到位图中?