仿照KK5.0聊天窗口布局

簡介:這個佈局分爲頭,中,底,三個模塊。

頭:對話名稱,返回按鈕。

中:對話的列表

底部:發送會話。


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>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章