Ich habe eine Messaging-Aktivität, in der ich möchte, dass der Benutzer in der messageField
eingeben kann und es dynamisch wachsen, wie der Text in die nächste Zeile fließt. Ich brauche auch ein Limit, wie weit es wachsen sollte, da der Benutzer immer noch die letzten Nachrichten sehen sollte, die gesendet wurden. Ich weiß nicht, wo ich anfangen soll. Jede Richtung würde geschätzt werden.Skalierung RelativeLayout nach Größe des Kindes TextView Inhalt
Relevante Inhalt meines chat_activity.xml: (Dies alles präsidiert in einem RelativeLayout
)
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/interactionHolder"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:layout_below="@+id/headerContainer"
android:id="@+id/contentFrameLayout">
<ListView
android:id="@+id/messageListView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:transcriptMode="disabled"
android:smoothScrollbar="false"
android:dividerHeight="5dp"
android:divider="@null"
android:drawSelectorOnTop="false"
android:listSelector="@android:color/transparent"
android:cacheColorHint="#00000000" />
</FrameLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:id="@+id/interactionHolder"
android:layout_alignParentBottom="true"
android:visibility="visible">
<RelativeLayout
android:id="@+id/textfieldcontainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="false"
android:layout_alignParentRight="false"
android:layout_gravity="bottom"
android:alignmentMode="alignMargins"
android:background="#ff9d9d9d"
>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/photoButton"
android:scaleType="centerCrop"
android:src="@android:drawable/ic_menu_camera"
android:layout_alignParentLeft="true"
android:background="#ff9d9d9d"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:contentDescription="@string/upload" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/voiceButton"
android:layout_toRightOf="@+id/photoButton"
android:focusable="false"
android:src="@android:drawable/ic_btn_speak_now"
android:scaleType="centerCrop"
android:background="#ff9d9d9d"
android:layout_centerVertical="true"
android:contentDescription="@string/voicenote" />
<EditText
android:id="@+id/messageField"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:ems="10"
android:gravity="left|center"
android:inputType="textMultiLine"
android:background="@android:drawable/editbox_background_normal"
android:textColor="#ff000000"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/voiceButton"
android:layout_toEndOf="@+id/voiceButton"
android:layout_toLeftOf="@+id/sendButton"
android:layout_toStartOf="@+id/sendButton" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/sendButton"
android:src="@android:drawable/ic_menu_send"
android:layout_alignParentRight="true"
android:background="#ff9d9d9d"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:contentDescription="@string/sendbutton"
android:clickable="true" />
</RelativeLayout>
</RelativeLayout>
, aber es ist nicht arbeite in meinem Setup oben. Ich denke, ich muss mein relatives Layout vergrößern, weiß aber nicht wie? – Stephan
@Stephan Überprüfen Sie meine Post Update über – Shaishav
Danke, wie halte ich die Bild-Schaltflächen auf der Unterseite ihrer Eltern? – Stephan