安卓键盘如何剪切EditText中的文本

4

你好,我有一个包含多个textView的竖向滚动视图。

在底部我有一个EditText,就像一个聊天应用程序。 我在manifest中设置了android:windowSoftInputMode="adjustPan"。

问题是,当我点击editText时,我的布局会上移,这很好,但键盘会将我的editText裁剪成两半,就像图片中那样。

 <ScrollView
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="8"
    android:background="#CCCCCC" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"

        android:orientation="vertical" >
           //many textView
          <TextView
            android:id="@+id/text_area"
            android:layout_width="fill_parent"
            android:layout_height="50dp"
            android:background="#FF0000"
            android:layout_marginBottom="15dp"
            android:paddingLeft="10dp"
            android:textColor="#168191" />

          </LinearLayout>
</ScrollView>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:orientation="horizontal"
    android:weightSum="10" >

    <EditText
        android:id="@+id/send_msg"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="8"
        android:background="#CCDEDC"
        android:paddingLeft="20dp"
        android:text="Large Text"
        android:textColor="#168191"
        android:textSize="15dp" />
        <Button
        android:id="@+id/send_msg_btn"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="2"
        android:background="#CCCCCC"
        android:text="Send"
        android:textColor="#FFFFFF" />
</LinearLayout>

printscreen


我认为你需要将包含EditText和Button的LinearLayout也放入ScrollView中。它们不在ScrollView标签下,因此“adjustPan”对它们无效。 - Yogesh Somani
1
你需要检查所有给出的答案,这个问题。你一定会找到解决问题的方法。 - MKJParekh
2个回答

3
在AndroidManifest.xml文件中,为想要查看键盘“未裁剪”文本的活动添加以下选项:android:windowSoftInputMode="adjustPan|stateHidden" 更新:可能需要更改您的EditText样式的填充,因为它似乎是自定义的。

谢谢您的回复。我已经添加了 "android:windowSoftInputMode="adjustPan|stateHidden" 并且删除了左边距,但是问题仍然存在 :( - Catalin

1
在你的清单文件中的activity标签中使用android:windowSoftInputMode="adjustResize",这样可以让软键盘弹出时,所有的视图都显示在其上方。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接