【发布时间】:2014-11-21 19:24:43
【问题描述】:
我正在开发一个简单的 HelloWorld 应用程序来获取信息。该应用程序有一个 TextView 的简单嵌套线性布局,它填充了 EditText 和发送按钮上的大部分布局。每当输入文本并单击“发送”时,它会将文本作为新行添加到 TextView。到目前为止,其他一切都很好,但是每当弹出键盘开始输入文本时,上面的 TextView 也会被向上推。我希望 TextView 保持原位,并在布局中调整大小。
图片1:https://flic.kr/p/pRHo4j 图二:https://flic.kr/p/pRQg7i
谢谢, 疯了
XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView android:id="@+id/display_message"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:freezesText="true" />
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<EditText android:id="@+id/edit_message"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/edit_message" />
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_send"
android:onClick="sendMessage" />
</LinearLayout>
</LinearLayout>
【问题讨论】: