为什么在片段中,我的键盘没有推到顶部的视图

时间:2016-12-12 07:51:20

标签: android android-softkeyboard

为什么在键盘处于活动状态时片段,它不会将我的EditText推到mykeyboard的顶部?

活动

In Activity

在片段中

In Fragment

照片1,它在Activity中。键盘推视图到顶部 照片2,它在片段中。键盘没有推视图!!

2 个答案:

答案 0 :(得分:2)

在清单中添加您的活动代码:

  

机器人:windowSoftInputMode = “adjustPan”

<activity
        android:name=".MainActivity"
        android:windowSoftInputMode="adjustPan"/>

答案 1 :(得分:0)

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">

<ListView
    android:layout_marginBottom="60dp"
    android:layout_weight="1"
    android:id="@+id/listChat"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
</ListView>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/white"
    android:orientation="horizontal"
    android:padding="10dp"
    android:layout_alignParentBottom="true">

    <EditText
        android:id="@+id/edtContent"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginRight="15dp"
        android:layout_weight="1"
        android:background="@drawable/chat_textbox"
        android:hint="comment"
        android:paddingLeft="10dp"
        android:textSize="12sp"
        android:textStyle="italic" />

    <TextView
        android:id="@+id/btnSend"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/send_button"
        android:textColor="@color/white" />
</LinearLayout>

和我的清单

 <activity android:name=".ActivityHome" android:windowSoftInputMode="adjustPan" >

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

我在Fragment中使用它