仿照KK5.0聊天窗口布局

本文详细介绍了如何使用RelativeLayout、LinearLayout和FrameLayout等布局管理器来构建一个包含头、中、底三个模块的聊天应用界面。通过设置对话列表、发送会话等功能,并解决底部布局被ListView覆盖的问题,实现了一个简洁且功能完善的聊天应用布局。

简介:这个布局分为头,中,底,三个模块。

头:对话名称,返回按钮。

中:对话的列表

底部:发送会话。


1.首先我是使用RelativeLayout布局的,三个模块先独立完成,然后中的对话列表设为在头之下在底之上layout_above,layout_below实现。


2.后来使用linearlayout,无论使用RelativeLayout,还是android:layout_marginBottom都发现,底部的发送会话的布局没有出来。

都被listview控件占了布局空间。

之后使用了FrameLayout将listview控件包裹,才解决了这个问题。理论,继续学习ing。先记录后理解理论。


<LinearLayout 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:orientation="vertical"
    android:id="@+id/main">
    
    <LinearLayout
        android:id="@+id/id_ly_top"
        android:layout_width="fill_parent"
        android:layout_height="40dp"
        android:background="@drawable/title_bar">
        
        <TextView
                android:id="@+id/chat_back_name"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center_vertical"
                android:background="@drawable/back_selector"
                android:gravity="center"
                android:paddingLeft="5dip" />
        
        <TextView 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal"
            android:textColor="#ffffff"
            android:textSize="22sp"
            android:text="傻木" />"
            
    </LinearLayout>
    
    <!-- 中间部分内容 -->
<FrameLayout
             android:layout_width="match_parent"
             android:layout_height="0dip"
             android:layout_gravity="center"
             android:layout_weight="1" >
  
   <ListView
       android:id="@+id/item_list_msg"
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:background="#0000"
       android:cacheColorHint="#00000000"
       android:divider="@null"
       android:dividerHeight="20dip"
       android:footerDividersEnabled="true"
       android:overScrollMode="never"
       android:scrollbars="none"
       android:stackFromBottom="true" >


    </ListView>
    </FrameLayout>




     <LinearLayout
         android:id="@+id/id_ly_bottom"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_marginBottom="5dp"
         android:gravity="center"
         android:orientation="horizontal"
         android:visibility="visible" >


         <Button
             android:id="@+id/change_type"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:background="@drawable/voice_button_selector"
             android:gravity="center" />


         <FrameLayout
             android:layout_width="0dip"
             android:layout_height="wrap_content"
             android:layout_gravity="center"
             android:layout_weight="1" >


             <EditText
                 android:id="@+id/send_to_msg"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
                 android:layout_gravity="center"
                 android:background="@drawable/input_bg"
                 android:hint="@string/kk_chat_inputmsg_hint"
                 android:maxLines="3" />


             <TextView
                 android:id="@+id/record_button"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
                 android:layout_gravity="center"
                 android:background="@drawable/voice_recording_selector"
                 android:gravity="center"
                 android:padding="5dip"
                 android:text="@string/kk_chat_record_voice_hint"
                 android:textColor="#000000"
                 android:visibility="gone" />
         </FrameLayout>


         <ImageView
             android:id="@+id/face_btn"
             android:layout_width="35dip"
             android:layout_height="35dip"
             android:layout_marginLeft="3dip"
             android:background="@drawable/face_selector"
             android:contentDescription="test" />


         <FrameLayout
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_gravity="center"
             android:gravity="center" >


             <Button
                 android:id="@+id/send_to"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:background="@drawable/chat_send_to"
                 android:gravity="center"
                 android:visibility="gone" />


             <Button
                 android:id="@+id/send_plus"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:background="@drawable/change_chat_image"
                 android:gravity="center" />
         </FrameLayout>
     </LinearLayout>


<!-- </LinearLayout> -->
</LinearLayout>

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值