繁体   English   中英

弹出键盘时向上移动布局

[英]Shifting layout up when keyboard pops up

因此,我在屏幕底部有一个EditText供用户输入,当我单击它时,键盘会弹出并向上移动,但问题是如何移动。 而不是使用键盘移动EditText ,而是将显示键盘,并且半秒钟后, EditText会固定到位。 当我关闭键盘时, 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>

尝试设定

android:windowSoftInputMode="adjustResize"

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

在AndroidManifest.xml中尝试以下操作,在其中声明主动性,其中包含正在工作的片段

 android:windowSoftInputMode="adjustPan"

让我知道是否可行

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM