チャットセッションを表示するフラグメントがあり、その下にEditText
とButton
現在、RelativeLayout
を含む高さEditText
とButton
ハードコードされています。
RelativeLayout
高さを1行の高さだけにする方法EditText
と、ユーザーが新しいテキスト行を保証するのに十分なテキストを入力したときに、高さを動的にサイズ変更して、今より大きくなった高さを含めるにはどうすればよいEditText
ですか?
Google Voiceアプリまたはストックメッセージングアプリを使用したことがある人は、メッセージに返信するときにこれが実際に動作していることを確認できます。
現在のレイアウトを以下に示します。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:id="@+id/bottom_bar"
android:layout_width="fill_parent"
android:layout_height="90dp"
android:layout_alignParentBottom="true"
android:minHeight="60dp" >
<ImageButton
android:id="@+id/sendButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="false"
android:layout_alignParentRight="true"
android:layout_centerInParent="false"
android:layout_centerVertical="true"
android:background="@null"
android:onClick="sendMessage"
android:paddingBottom="15dp"
android:paddingRight="5dp"
android:paddingTop="10dp"
android:src="@drawable/send" />
<EditText
android:id="@+id/sendText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="false"
android:layout_centerVertical="true"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:layout_toLeftOf="@id/sendButton"
android:hint="Enter Message"
android:inputType="textMultiLine" >
</EditText>
</RelativeLayout>
<fragment
android:id="@+id/chatfragment"
android:name="android.support.v4.app.ListFragment"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@id/bottom_bar"
android:layout_alignParentTop="true" />
</RelativeLayout>