【发布时间】:2015-04-18 20:12:12
【问题描述】:
我对此很陌生,对 Android 编程也很陌生。
我正在尝试制作类似于 WhatsApp 聊天活动中的布局。所以我想要实现的是获得与 EditText 和它旁边的按钮相同的布局和行为。 这意味着中间有一个用于笑脸和 EditText 的左侧按钮,以及用于发送文本的右侧的一个按钮。
在 WhatsApp 中,当 EditText 扩展其大小(多行)时,按钮会停留在底部。但它似乎不是父视图的底部,因为按钮之前已经以 EditText 为中心。
我尝试了很多方法,比如将三个视图放在 TableLayout 的行中。或者只是使用RelativeLayout。但它没有任何工作正常。
谁能告诉我如何做到这一点?我可以提供我的 XML,但是……嗯……这显然很糟糕:D
提前致谢!
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin">
<ListView
android:id="@+id/messages"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_above="@+id/footer_section">
</ListView>
<LinearLayout
android:id="@+id/footer_section"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:minHeight="48dp">
<ImageView
android:id="@+id/emoticons_button"
android:layout_height="match_parent"
android:layout_width="48dp"
/>
<EditText
android:id="@+id/message_text"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_weight="1"
android:inputType="textMultiLine"
android:minLines="1"
android:maxLines="4"/>
<ImageView
android:id="@+id/send_button"
android:layout_height="match_parent"
android:layout_width="48dp"
android:layout_gravity="center_vertical"/>
</LinearLayout>
【问题讨论】:
-
请提供您的xml
标签: android button layout android-edittext multiline