当我点击EditText时,键盘会弹出并覆盖EditText的一部分。我希望EditText 完全可见。
我尝试过adjustPan和adjustResize但它们无法正常工作。我想在片段中这样做。
这就是它现在的样子
这就是我想要的方式
更新
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#EAEAEA"
android:clickable="true" >
<RelativeLayout
android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:background="@android:color/white" >
<TextView
android:id="@+id/message_header"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="15dp"
android:layout_marginStart="15dp"
android:gravity="center_vertical"
android:text="@string/messages"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/black" />
<ImageView
android:id="@+id/close_button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginEnd="5dp"
android:layout_marginRight="5dp"
android:contentDescription="@null"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:src="@drawable/close" />
</RelativeLayout>
<ListView
android:id="@+id/message_area"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/edit_control"
android:layout_below="@+id/imageSmsProfile"
android:background="#EAEAEA"
android:divider="@null"
android:dividerHeight="0dp"
android:fadeScrollbars="true"
android:overScrollHeader="#EAEAEA" >
</ListView>
<com.monqi.kid.custom.CustomRoundedImageView
android:id="@+id/imageSmsProfile"
android:layout_width="@dimen/dimen_50dp"
android:layout_height="@dimen/dimen_50dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:background="@drawable/rounded_rectangle_shape"
android:scaleType="centerCrop"
app:left_bottom_corner_radius="10dip"
app:left_top_corner_radius="10dip"
app:right_bottom_corner_radius="10dip"
app:right_top_corner_radius="10dip" />
<RelativeLayout
android:id="@+id/edit_control"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:paddingLeft="5dp"
android:paddingRight="5dp" >
<EditText
android:id="@+id/input_chat_message"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="2dp"
android:layout_marginLeft="5dp"
android:layout_toLeftOf="@+id/button_chat_send"
android:layout_toStartOf="@+id/button_chat_send"
android:background="@drawable/edittext_drawable"
android:cursorVisible="false"
android:ems="10"
android:inputType="textImeMultiLine"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingStart="10dp" >
<requestFocus />
</EditText>
<Button
android:id="@+id/button_chat_send"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="2dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="2dp"
android:background="@drawable/send_button"
android:text="@string/send"
android:textColor="@android:color/white" />
</RelativeLayout>
</RelativeLayout>
答案 0 :(得分:1)
使用android:windowSoftInputMode="adjustResize|adjustPan"
答案 1 :(得分:0)
当我遇到我在onCreate()中添加以下代码行的情况时,这对我有用,希望这有帮助
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
答案 2 :(得分:0)
试试这个xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="80dp">
</ListView>
<RelativeLayout
android:id="@+id/form"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:orientation="vertical" >
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:ems="10"
android:id="@+id/chatText"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_toLeftOf="@+id/buttonSend" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send"
android:id="@+id/buttonSend"
android:layout_alignBottom="@+id/chatText"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
答案 3 :(得分:0)
添加android:windowSoftInputMode =&#34; adjustResize | adjustResize&#34;在AndroidManifest中使用scrollView包含你的rootView。