Reputation: 583
I have a little Chat application. At the bottom is the EditText line and a send button. In the EditText maxLines is set to 5. How can I move the button always to center_horizontal, even if new lines (1-5) are added to the textview? The button actually just stays at it's position.
My try:
<LinearLayout
android:id="@+id/llLine"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:gravity="center_horizontal"
android:layout_height="wrap_content" >
<EditText
android:id="@+id/txtChatline"
android:layout_width="0dp"
android:layout_weight="0.70"
android:hint="@string/hint_message"
android:layout_height="wrap_content"
android:maxLength="500"
android:maxLines="5"
android:ems="10" />
<Button
android:id="@+id/cmdSendMessage"
android:layout_width="0dp"
android:layout_weight="0.30"
android:enabled="false"
android:gravity="center"
android:layout_height="wrap_content"
android:text="@string/send" />
</LinearLayout>
Upvotes: 0
Views: 909
Reputation: 55340
If your EditText
grows vertically, you need to use android:gravity="center_vertical"
.
(or android:gravity="center"
if you want to use both, but I assume it was a mistake).
Upvotes: 1