Skip to content

Commit 368ff73

Browse files
authored
Remove RelativeLayout from Firestore quickstart (#1245)
1 parent 46ffd96 commit 368ff73

File tree

6 files changed

+379
-284
lines changed

6 files changed

+379
-284
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
<androidx.constraintlayout.widget.ConstraintLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
34
xmlns:app="http://schemas.android.com/apk/res-auto"
45
xmlns:tools="http://schemas.android.com/tools"
56
android:layout_width="match_parent"
@@ -12,6 +13,9 @@
1213
android:layout_height="wrap_content"
1314
android:background="@color/colorPrimary"
1415
android:theme="@style/AppTheme"
16+
app:layout_constraintEnd_toEndOf="parent"
17+
app:layout_constraintStart_toStartOf="parent"
18+
app:layout_constraintTop_toTopOf="parent"
1519
app:logo="@drawable/ic_restaurant_white_24px"
1620
app:popupTheme="@style/Theme.AppCompat.Light.DarkActionBar"
1721
app:title="@string/app_name"
@@ -22,11 +26,13 @@
2226
android:id="@+id/filterBarContainer"
2327
android:layout_width="match_parent"
2428
android:layout_height="wrap_content"
25-
android:layout_below="@+id/toolbar"
2629
android:background="@color/colorPrimary"
27-
android:paddingBottom="12dp"
2830
android:paddingLeft="12dp"
29-
android:paddingRight="12dp">
31+
android:paddingRight="12dp"
32+
android:paddingBottom="12dp"
33+
app:layout_constraintEnd_toEndOf="parent"
34+
app:layout_constraintStart_toStartOf="parent"
35+
app:layout_constraintTop_toBottomOf="@+id/toolbar">
3036

3137
<androidx.cardview.widget.CardView
3238
android:id="@+id/filterBar"
@@ -36,61 +42,64 @@
3642
android:elevation="12dp"
3743
android:foreground="?attr/selectableItemBackground">
3844

39-
<RelativeLayout
45+
<androidx.constraintlayout.widget.ConstraintLayout
4046
android:layout_width="match_parent"
4147
android:layout_height="wrap_content"
42-
android:gravity="center_vertical">
48+
android:paddingTop="8dp"
49+
android:paddingBottom="8dp">
4350

4451
<ImageView
4552
android:id="@+id/buttonFilter"
4653
android:layout_width="wrap_content"
4754
android:layout_height="wrap_content"
4855
android:layout_centerVertical="true"
49-
android:padding="8dp"
50-
app:tint="@color/greySecondary"
51-
app:srcCompat="@drawable/ic_filter_list_white_24px" />
52-
53-
<LinearLayout
54-
android:id="@+id/textCurrentSearchContainer"
56+
android:layout_marginLeft="8dp"
57+
android:layout_marginRight="8dp"
58+
app:layout_constraintBottom_toBottomOf="parent"
59+
app:layout_constraintStart_toStartOf="parent"
60+
app:layout_constraintTop_toTopOf="parent"
61+
app:srcCompat="@drawable/ic_filter_list_white_24px"
62+
app:tint="@color/greySecondary" />
63+
64+
<TextView
65+
android:id="@+id/textCurrentSearch"
66+
style="@style/AppTheme.Body1"
5567
android:layout_width="wrap_content"
5668
android:layout_height="wrap_content"
57-
android:layout_centerVertical="true"
58-
android:layout_marginLeft="8dp"
59-
android:layout_toRightOf="@+id/buttonFilter"
60-
android:orientation="vertical"
61-
android:paddingBottom="8dp"
62-
android:paddingTop="8dp">
63-
64-
<TextView
65-
android:id="@+id/textCurrentSearch"
66-
style="@style/AppTheme.Body1"
67-
android:layout_width="wrap_content"
68-
android:layout_height="wrap_content"
69-
android:text="@string/all_restaurants"
70-
android:textColor="@color/greySecondary"
71-
tools:text="Filter" />
72-
73-
<TextView
74-
android:id="@+id/textCurrentSortBy"
75-
style="@style/AppTheme.Caption"
76-
android:layout_width="wrap_content"
77-
android:layout_height="wrap_content"
78-
android:text="@string/sorted_by_rating"
79-
android:textColor="@color/greyDisabled" />
80-
81-
</LinearLayout>
69+
android:layout_marginStart="16dp"
70+
android:layout_marginLeft="16dp"
71+
android:text="@string/all_restaurants"
72+
android:textColor="@color/greySecondary"
73+
app:layout_constraintStart_toEndOf="@+id/buttonFilter"
74+
app:layout_constraintTop_toTopOf="parent"
75+
tools:text="Filter" />
76+
77+
<TextView
78+
android:id="@+id/textCurrentSortBy"
79+
style="@style/AppTheme.Caption"
80+
android:layout_width="wrap_content"
81+
android:layout_height="wrap_content"
82+
android:text="@string/sorted_by_rating"
83+
android:textColor="@color/greyDisabled"
84+
app:layout_constraintBottom_toBottomOf="parent"
85+
app:layout_constraintStart_toStartOf="@+id/textCurrentSearch"
86+
app:layout_constraintTop_toBottomOf="@+id/textCurrentSearch" />
8287

8388
<ImageView
8489
android:id="@+id/buttonClearFilter"
8590
android:layout_width="wrap_content"
8691
android:layout_height="wrap_content"
87-
android:layout_alignParentRight="true"
8892
android:layout_centerVertical="true"
93+
android:layout_marginEnd="8dp"
94+
android:layout_marginRight="8dp"
8995
android:padding="8dp"
90-
app:tint="@color/greySecondary"
91-
app:srcCompat="@drawable/ic_close_white_24px" />
96+
app:layout_constraintBottom_toBottomOf="parent"
97+
app:layout_constraintEnd_toEndOf="parent"
98+
app:layout_constraintTop_toTopOf="parent"
99+
app:srcCompat="@drawable/ic_close_white_24px"
100+
app:tint="@color/greySecondary" />
92101

93-
</RelativeLayout>
102+
</androidx.constraintlayout.widget.ConstraintLayout>
94103

95104
</androidx.cardview.widget.CardView>
96105

@@ -100,29 +109,35 @@
100109
<androidx.recyclerview.widget.RecyclerView
101110
android:id="@+id/recyclerRestaurants"
102111
android:layout_width="match_parent"
103-
android:layout_height="wrap_content"
104-
android:layout_below="@+id/filterBarContainer"
112+
android:layout_height="0dp"
105113
android:background="@android:color/white"
114+
app:layout_constraintBottom_toBottomOf="parent"
115+
app:layout_constraintEnd_toEndOf="parent"
116+
app:layout_constraintStart_toStartOf="parent"
117+
app:layout_constraintTop_toBottomOf="@+id/filterBarContainer"
106118
tools:listitem="@layout/item_restaurant" />
107119

108120
<!-- Shadow below toolbar -->
109121
<View
122+
android:id="@+id/view"
110123
android:layout_width="match_parent"
111124
android:layout_height="4dp"
112-
android:layout_below="@+id/filterBarContainer"
113-
android:background="@drawable/bg_shadow" />
125+
android:background="@drawable/bg_shadow"
126+
app:layout_constraintTop_toBottomOf="@+id/filterBarContainer"
127+
/>
114128

115129
<!-- Empty list (pizza guy) view -->
116130
<LinearLayout
117131
android:id="@+id/viewEmpty"
118132
android:layout_width="wrap_content"
119133
android:layout_height="wrap_content"
120-
android:layout_alignParentBottom="true"
121-
android:layout_below="@+id/toolbar"
122-
android:layout_centerHorizontal="true"
123-
android:gravity="center"
124134
android:orientation="vertical"
125135
android:visibility="gone"
136+
app:layout_constraintBottom_toBottomOf="parent"
137+
app:layout_constraintEnd_toEndOf="parent"
138+
app:layout_constraintStart_toStartOf="parent"
139+
app:layout_constraintTop_toBottomOf="@+id/toolbar"
140+
tools:ignore="UseCompoundDrawables"
126141
tools:visibility="gone">
127142

128143
<ImageView
@@ -133,7 +148,6 @@
133148
style="@style/AppTheme.Body1"
134149
android:layout_width="wrap_content"
135150
android:layout_height="wrap_content"
136-
android:gravity="center"
137151
android:text="@string/message_no_results"
138152
android:textColor="@color/greyDisabled" />
139153

@@ -143,9 +157,12 @@
143157
android:id="@+id/progressLoading"
144158
android:layout_width="wrap_content"
145159
android:layout_height="wrap_content"
146-
android:layout_alignBottom="@+id/recyclerRestaurants"
147-
android:layout_alignTop="@+id/recyclerRestaurants"
148160
android:layout_centerHorizontal="true"
149-
android:visibility="gone" />
161+
android:visibility="gone"
162+
app:layout_constraintBottom_toBottomOf="@+id/recyclerRestaurants"
163+
app:layout_constraintEnd_toEndOf="parent"
164+
app:layout_constraintStart_toStartOf="parent"
165+
app:layout_constraintTop_toTopOf="@+id/recyclerRestaurants"
166+
/>
150167

151-
</RelativeLayout>
168+
</androidx.constraintlayout.widget.ConstraintLayout>

0 commit comments

Comments
 (0)