結對作業5

新晋软工小白發表於2024-06-11

實現聊天介面

  1 <?xml version="1.0" encoding="utf-8"?>
  2 <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3     xmlns:app="http://schemas.android.com/apk/res-auto"
  4     xmlns:tools="http://schemas.android.com/tools"
  5     android:layout_width="match_parent"
  6     android:layout_height="match_parent"
  7     android:animateLayoutChanges="true"
  8     android:background="@color/primary"
  9     tools:context=".activities.ChatActivity">
 10 
 11     <View
 12         android:id="@+id/viewBackground"
 13         android:layout_width="match_parent"
 14         android:layout_height="0dp"
 15         android:layout_marginBottom="@dimen/_16sdp"
 16         android:background="@drawable/background_content_top"
 17         app:layout_constraintBottom_toTopOf="@+id/layoutSend"
 18         app:layout_constraintTop_toTopOf="parent" />
 19 
 20     <View
 21         android:id="@+id/headerBackground"
 22         android:layout_width="match_parent"
 23         android:layout_height="0dp"
 24         android:background="@color/primary"
 25         app:layout_constraintBottom_toTopOf="@+id/viewSupporter"
 26         app:layout_constraintTop_toTopOf="parent"/>
 27 
 28     <androidx.appcompat.widget.AppCompatImageView
 29         android:id="@+id/imageBack"
 30         android:layout_width="@dimen/_30sdp"
 31         android:layout_height="@dimen/_30sdp"
 32         android:layout_marginStart="@dimen/_16sdp"
 33         android:layout_marginLeft="@dimen/_16sdp"
 34         android:layout_marginTop="@dimen/_12sdp"
 35         android:padding="@dimen/_5sdp"
 36         android:src="@drawable/ic_back"
 37         app:layout_constraintStart_toStartOf="parent"
 38         app:layout_constraintTop_toTopOf="parent"
 39         app:tint="@color/white"/>
 40 
 41     <androidx.appcompat.widget.AppCompatImageView
 42         android:id="@+id/imageInfo"
 43         android:layout_width="@dimen/_30sdp"
 44         android:layout_height="@dimen/_30sdp"
 45         android:layout_marginTop="@dimen/_12sdp"
 46         android:layout_marginEnd="@dimen/_16sdp"
 47         android:layout_marginRight="@dimen/_16sdp"
 48         android:padding="@dimen/_4sdp"
 49         android:src="@drawable/ic_info"
 50         app:layout_constraintEnd_toEndOf="parent"
 51         app:layout_constraintTop_toTopOf="parent"
 52         app:tint="@color/white"/>
 53 
 54     <TextView
 55         android:id="@+id/textName"
 56         android:layout_width="0dp"
 57         android:layout_height="wrap_content"
 58         android:layout_marginStart="@dimen/_8sdp"
 59         android:layout_marginEnd="@dimen/_8sdp"
 60         android:ellipsize="end"
 61         android:gravity="center"
 62         android:maxLines="1"
 63         android:textColor="@color/white"
 64         android:textSize="@dimen/_14ssp"
 65         android:textStyle="bold"
 66         app:layout_constraintBottom_toBottomOf="@+id/imageBack"
 67         app:layout_constraintEnd_toStartOf="@+id/imageInfo"
 68         app:layout_constraintStart_toEndOf="@+id/imageBack"
 69         app:layout_constraintTop_toTopOf="@+id/imageBack" />
 70 
 71     <View
 72         android:id="@+id/viewSupporter"
 73         android:layout_width="match_parent"
 74         android:layout_height="1dp"
 75         android:background="@color/primary"
 76         android:layout_marginTop="@dimen/_12sdp"
 77         app:layout_constraintTop_toBottomOf="@id/imageBack"/>
 78 
 79     <TextView
 80         android:id="@+id/textAvailability"
 81         android:layout_width="match_parent"
 82         android:layout_height="wrap_content"
 83         android:background="#008000"
 84         android:padding="@dimen/_2sdp"
 85         android:text="@string/online"
 86         android:gravity="center"
 87         android:textColor="@color/white"
 88         android:textSize="@dimen/_10ssp"
 89         android:visibility="gone"
 90         app:layout_constraintTop_toBottomOf="@id/viewSupporter"/>
 91 
 92     <androidx.recyclerview.widget.RecyclerView
 93         android:id="@+id/chatRecyclerView"
 94         android:layout_width="match_parent"
 95         android:layout_height="0dp"
 96         android:clipToPadding="false"
 97         android:orientation="vertical"
 98         android:overScrollMode="never"
 99         android:padding="@dimen/_20sdp"
100         app:stackFromEnd="true"
101         android:visibility="gone"
102         app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
103         app:layout_constraintBottom_toBottomOf="@id/viewBackground"
104         app:layout_constraintTop_toBottomOf="@+id/textAvailability"/>
105 
106     <ProgressBar
107         android:id="@+id/progressBar"
108         android:layout_width="@dimen/_25sdp"
109         android:layout_height="@dimen/_25sdp"
110         app:layout_constraintBottom_toBottomOf="@+id/viewBackground"
111         app:layout_constraintEnd_toEndOf="@id/viewBackground"
112         app:layout_constraintStart_toStartOf="@+id/viewBackground"
113         app:layout_constraintTop_toTopOf="@id/viewBackground" />
114 
115     <FrameLayout
116         android:id="@+id/layoutSend"
117         android:layout_width="@dimen/_40sdp"
118         android:layout_height="@dimen/_40sdp"
119         android:layout_marginEnd="@dimen/_16sdp"
120         android:layout_marginBottom="@dimen/_12sdp"
121         android:background="@drawable/background_chat_input"
122         app:layout_constraintBottom_toBottomOf="parent"
123         app:layout_constraintEnd_toEndOf="parent">
124 
125         <androidx.appcompat.widget.AppCompatImageView
126             android:layout_width="match_parent"
127             android:layout_height="match_parent"
128             android:layout_marginStart="@dimen/_4sdp"
129             android:layout_marginLeft="@dimen/_4sdp"
130             android:padding="@dimen/_8sdp"
131             android:src="@drawable/ic_send"
132             app:tint="@color/white" />
133 
134     </FrameLayout>
135 
136     <EditText
137         android:id="@+id/inputMessage"
138         android:layout_width="0dp"
139         android:layout_height="@dimen/_40sdp"
140         android:layout_marginStart="@dimen/_16sdp"
141         android:layout_marginLeft="@dimen/_16sdp"
142         android:layout_marginEnd="@dimen/_8sdp"
143         android:layout_marginRight="@dimen/_8sdp"
144         android:layout_marginBottom="@dimen/_12sdp"
145         android:background="@drawable/background_chat_input"
146         android:hint="@string/type_a_message"
147         android:imeOptions="actionDone"
148         android:importantForAutofill="no"
149         android:inputType="text"
150         android:paddingStart="@dimen/_16sdp"
151         android:paddingEnd="@dimen/_16sdp"
152         android:textColor="@color/white"
153         android:textColorHint="@color/secondary_text"
154         app:layout_constraintBottom_toBottomOf="parent"
155         app:layout_constraintEnd_toStartOf="@+id/layoutSend"
156         app:layout_constraintStart_toStartOf="parent" />
157 
158 </androidx.constraintlayout.widget.ConstraintLayout>

相關文章