界面简化一下,一个listview显示消息队列,一个横向linearlayout显示一个文本框和一个输入按钮,一个横向linearlayout显示两个图片button,上下顺序也是这个顺序,下面两个linearlayout放在底部, 我是通过设置layout_weight的方式实现的,代码如下
- XML code
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@color/gray" android:orientation="vertical"> <LinearLayout android:id="@+id/body" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:orientation="vertical" android:weightSum="1"> <ListView android:id="@+id/chat_list" android:cacheColorHint="@null" android:divider="@drawable/divider_group" android:groupIndicator="@drawable/expand_group" android:listSelector="@drawable/list_alpha_selector" android:transcriptMode="alwaysScroll" android:layout_height="346dp" android:layout_weight="1.05" android:layout_width="wrap_content" /> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="0" android:background="@color/gray_blue" android:gravity="center_vertical"> <Button android:id="@+id/chat_emotion" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" android:background="@drawable/chat_emotion_selector" /> <EditText android:id="@+id/chat_input" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:background="@drawable/chat_input_selector" android:singleLine="true" /> <Button android:id="@+id/chat_send" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="0" android:background="@drawable/button" android:onClick="onClick" android:text="发送" android:textColor="@color/white" android:textSize="18dip" /> </LinearLayout> </LinearLayout> <LinearLayout android:id="@+id/bottom" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="0" android:background="@drawable/bottom"> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center_horizontal"> <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:background="@drawable/option_selector" /> </LinearLayout> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center_horizontal"> <ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:background="@drawable/add_selector" /> </LinearLayout> </LinearLayout> </LinearLayout>