。
The layout file is as follows
<?xml version= "1.0" encoding= "Utf-8"? ><relativelayout xmlns:android= "http://schemas.android.com/apk/res/ Android "android:orientation=" vertical "android:layout_width=" fill_parent "android:layout_height=" Fill_parent " ><tablelayout android:id= "@+id/bottom_content" android:layout_width= "Fill_parent" android:layout_height= " 50DP "android:layout_alignparentbottom=" true "> <TableRow> <tablerow android:layout_weight=" 3 "> <edittext android:hint = "@string/input_info" android:id = "@+id/messagetext"/> </TableRow> <tablerow android:layout_weight= "1" > <button android:text= "@string/send_msg" Android:id = " @+id/messagebutton "/> </TableRow> </TableRow></TableLayout> <listview android:id=" @+id/lis T "android:layout_width=" fill_parent "android:layout_height=" wrap_content "android:layout_alignparenttop =" Tru E "android:layout_above=" @+id/bOttom_content "/></relativelayout>
Make the input box 3/4 of the width of the screen, and the width of the Send button is 1/4 of the screen width.
However, when you enter too much text and close the input keyboard or open the input keyboard, the width of the input box will squeeze the Send button, and when the text width reaches a certain width, the send button will "disappear" (invisible State).
Here is a simple workaround: Set a listener Addtextchangedlistener for the edittext in Java code, listen for changes to the input, and then rewrite the OnTextChanged method so that the width of the input box is 3 of the full screen 4, the width of the Send button takes up 1/4 of the full screen.
The core code is as follows: You only need to set the input box and the Send button width in ontextchanged to 3/4 and 1/4 respectively.
Messagesend= (Button) Findviewbyid (R.id.messagebutton);
edittext= (EditText) Findviewbyid (R.id.messagetext); Edittext.addtextchangedlistener (new Textwatcher () {@ overridepublic void OnTextChanged (charsequence arg0, int arg1, int arg2, int arg3) {edittext.setwidth ((3*screenwidth)/4) ; Messagesend.setwidth (SCREENWIDTH/4);} @Overridepublic void beforetextchanged (charsequence arg0, int arg1, int arg2,int arg3) {} @Overridepublic void Aftertextch Anged (Editable arg0) {}}); <span style= "font-family:arial; Background-color: #ffffff "></span>
Chat page input box and send button layout issues Android