
我想在WhatsApp聊天活动中制作一个布局.所以我想要实现的是获得与EditText和它旁边的按钮相同的布局和行为.
这意味着在屏幕中间有一个用于表情符号的左按钮和一个EditText,另一个用于发送文本的按钮.
在WhatsApp中,当EditText扩展其大小(多行)时,按钮保持在底部.但它似乎不是父视图的底部因为按钮已经集中在EditText之前.
我尝试了很多将这三个视图放在tableLayout的行中.或者只使用relativeLayout.但它没有任何正常的工作.
谁能告诉我如何实现这一目标?我可以提供我的XML但……好吧……显然非常糟糕:D
提前致谢!
<relativeLayoutxmlns: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>解决方法 编辑
<ListVIEw androID:ID="@+ID/messages" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:layout_above="@+ID/footer_section" androID:layout_alignParenttop="true" ></ListVIEw><linearLayout androID:ID="@+ID/footer_section" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:layout_alignParentBottom="true" androID:orIEntation="horizontal" androID:background="#eeeeee"> <ImageVIEw androID:ID="@+ID/emoticons_button" androID:layout_wIDth="48dp" androID:layout_height="match_parent" /> <EditText androID:ID="@+ID/message_text" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:scrollbars="vertical" androID:fadeScrollbars="false" androID:layout_weight="1" androID:inputType="textMultiline" androID:maxlines="4" androID:minlines="1" androID:textcolor="@androID:color/black" /> <ImageVIEw androID:ID="@+ID/send_button" androID:layout_wIDth="48dp" androID:layout_height="match_parent" androID:layout_gravity="center_vertical" /></linearLayout>
正如你所说,你是AndroID的新手,你应该尝试使用线性布局来实现你想要的布局.
尝试下面的xml:
<?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:layout_wIDth="match_parent"androID:layout_height="match_parent"androID:orIEntation="horizontal"androID:weightSum="1" ><linearLayout androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content" androID:layout_margintop="1dip" androID:gravity="center_vertical" androID:orIEntation="horizontal" > <Imagebutton androID:ID="@+ID/btn_emoticon" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:src="@drawable/ic_emoticon" /> <EditText androID:ID="@+ID/chat_text" androID:layout_wIDth="0dip" androID:layout_height="wrap_content" androID:layout_weight="1.0" androID:paddingleft="8dp" androID:paddingRight="6dp" /> <Imagebutton androID:ID="@+ID/btn_send" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:src="@drawable/ic_send_grey" /></linearLayout></linearLayout>总结
以上是内存溢出为你收集整理的android – 类似WhatsApp的布局,用于多行EditText和旁边的按钮全部内容,希望文章能够帮你解决android – 类似WhatsApp的布局,用于多行EditText和旁边的按钮所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)