我有这个布局
它可以工作但是当键盘打开发送按钮并且编辑框保持在键盘上方(我想要它)但是键盘和键盘。编辑框&发送按钮被推到ListView(不应该发生)看图像
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#1E1E1E">
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="fill_parent"
android:layout_height="60.0dp"
android:id="@+id/linearLayout1">
<ImageView
android:src="@drawable/action_menu"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:id="@+id/imgMenu" />
<ImageView
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:id="@+id/imgwfLogo"
android:src="@drawable/wflogo" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/linearLayout4"
android:weightSum="1.5">
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/linearLayout2"
android:layout_weight="1.45">
<ListView
android:id="@+id/lstChat"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:stackFromBottom="true"
android:transcriptMode="alwaysScroll" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout3"
android:weightSum="1"
android:layout_weight="0.05">
<EditText
android:inputType="textMultiLine"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/txtChatMessage"
android:hint="Write here"
android:layout_weight="0.9"
android:layout_margin="5dp"
android:padding="10dp" />
<Button
android:text="Send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/btnChatSend"
android:layout_weight="0.1"
android:layout_margin="5dp" />
</LinearLayout>
</LinearLayout>
我的活动代码
[Activity(Label = "Workflow Management Internal Communication", WindowSoftInputMode = SoftInput.AdjustResize)]
// EDIT 我创建了以下方法,但是现在问题是这个方法应该在键盘打开后调用,有没有办法在Xamarin中监听键盘打开事件
void Scroll()
{
var list = FindViewById<ListView>(Resource.Id.lstChat);
list.TranscriptMode = TranscriptMode.Disabled;
var scrolX = list.ScrollX;
var scrollY = list.ScrollY;
_adapter.NotifyDataSetChanged();
list.SetSelectionFromTop(scrolX + _index, scrollY);
}