[英]android button beside of an EditText
I faced a problem designing the layout for a chat. 我在设计聊天布局时遇到问题。 My XML is listed below. 我的XML在下面列出。
So the layout consists of 3 parts: header ( RelativeLayout
with multiple Views inside it), the ListView and the footer ( RelativeLayout
with EditText
and a Button
). 因此,布局包括3个部分:标头( RelativeLayout
具有多个View),ListView和页脚( RelativeLayout
带有EditText
和Button
)。 The Send button is placed beside the EditText
, but the EditText
can expand to a maximum of 6 lines and I need the button to stay on the bottom. 发送按钮位于EditText
旁边,但是EditText
最多可以扩展到6行,我需要将该按钮保持在底部。 A can't use alignParentBottom
, since it causes wrong dependencies and the footer expands pushing the ListView
out of the screen. A不能使用alignParentBottom
,因为它会导致错误的依赖关系,并且页脚会展开,从而将ListView
推出屏幕。 I also tried to change the layout to a linear one, but still can't force the button to stay on the bottom when the ExitText
expands to allow multiline input. 我还尝试将布局更改为线性布局,但是当ExitText
扩展以允许多行输入时,仍然不能强制按钮停留在底部。 Any suggestions are appreciated. 任何建议表示赞赏。
<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"
tools:context=".ChatActivity" >
<RelativeLayout
android:id="@+id/RL_header"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="#7B7B7B"
android:gravity="center_vertical" >
<ImageView
android:id="@+id/img_Contact_Icon"
android:layout_width="55dp"
android:layout_height="55dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:padding="5dp"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/tvContactName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/img_Contact_Icon"
android:layout_toRightOf="@+id/img_Contact_Icon"
android:text="testname"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/tvPartnerRegion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/img_Contact_Icon"
android:layout_alignLeft="@+id/tvContactName"
android:layout_marginBottom="5dp"
android:text="@string/tvFrom"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/RL_footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
>
<EditText
android:id="@+id/etChatInput"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@+id/btnSend"
android:ems="10"
android:hint="@string/etWriteMessageHint"
android:maxLines="6" />
<Button
android:id="@+id/btnSend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:text="@string/btnSend" />
</RelativeLayout>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/RL_footer"
android:layout_below="@+id/RL_header"
android:layout_centerHorizontal="true"
android:divider="@android:color/transparent"
android:dividerHeight="10.0sp" >
</ListView>
<LinearLayout
android:id="@+id/lay"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#000000"
android:gravity="center|left"
android:orientation="horizontal"
android:weightSum="3" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.8"
android:gravity="center"
android:padding="10dip" >
<EditText
android:id="@+id/Box"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/message_focus"
android:hint="message_title"
android:imeOptions="actionDone"
android:padding="8dip"
android:singleLine="true"
android:textColor="#333"
android:textSize="12dip" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="0.6"
android:gravity="center"
android:paddingLeft="5dip" >
<Button
android:id="@+id/Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_launcher" />
</LinearLayout>
</LinearLayout>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.