1

チャットセッションを表示するフラグメントがあり、その下にEditTextButton

現在、RelativeLayoutを含む高さEditTextButtonハードコードされています。

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>
4

1 に答える 1

3

ネストされた RelativeLayout の高さを に設定しようとしましたwrap_contentか?

<RelativeLayout
    android:id="@+id/bottom_bar"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:minHeight="60dp" >
于 2012-07-31T16:54:28.813 に答える