键盘弹出时向上移动布局

时间:2016-08-01 20:58:04

标签: java android android-layout

所以我在屏幕底部有一个EditText用于用户输入,当我点击它时,键盘弹出并将其向上移动,但问题在于它是如何移动的。键盘将显示半秒钟,而不是用键盘移动EditTextEditText会被卡入到位。当我关闭键盘时,EditText保持延长的大小半秒钟,然后再回到原始尺寸。

问题是,是否有可能实现平稳过渡?

不确定这是否会影响结果但是在Fragment

之内
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:backgroundTint="#c1c1c1">

    <ListView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/ListViewChat"
        android:layout_alignParentLeft="false"
        android:layout_alignParentStart="false"
        android:dividerHeight="1dp"
        android:layout_alignParentRight="false"
        android:layout_alignParentEnd="false"
        android:layout_below="@+id/tabs"
        android:layout_above="@+id/relativeLayout4" />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@android:color/transparent"
        android:id="@+id/relativeLayout4"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true">

        <EditText
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/editTextMessage"
            android:hint="Enter a message..."
            android:background="@android:color/transparent"
            android:layout_alignBottom="@+id/buttonSend"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_alignParentTop="true"
            android:layout_toLeftOf="@+id/buttonSend"
            android:layout_toStartOf="@+id/buttonSend"
            android:layout_marginLeft="20dp"
            android:layout_marginTop="10dp"
            android:layout_marginBottom="10dp"
            android:maxLength="120"
            android:singleLine="true"/>

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Send"
            android:id="@+id/buttonSend"
            android:layout_alignParentTop="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentEnd="true"
            android:background="@null" />

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/imageView5"
            android:src="@drawable/linebreak2px"
            android:layout_alignParentTop="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true" />
    </RelativeLayout>

</RelativeLayout>

2 个答案:

答案 0 :(得分:0)

尝试设置

{{1}}

在您的AndroidManifest.xml内,在您的活动中,让我知道它是否有效

答案 1 :(得分:0)

在您的AndroidManifest.xml中尝试以下操作,其中声明您的活动,其中包含您正在使用的片段

 android:windowSoftInputMode="adjustPan"

让我知道它是否有效

相关问题