Skip to content

Commit 8bb87cb

Browse files
committed
Fix FadeThrough catalog demo on API 21 and 22.
GridLayout needs to use the app: namespace for column and row attributes for API 21 and 22. PiperOrigin-RevId: 304206794
1 parent 74921bb commit 8bb87cb

File tree

4 files changed

+67
-76
lines changed

4 files changed

+67
-76
lines changed

catalog/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ dependencies {
1010

1111
api 'androidx.multidex:multidex:2.0.0'
1212
api 'androidx.constraintlayout:constraintlayout:1.1.3'
13+
api 'androidx.gridlayout:gridlayout:1.0.0'
1314

1415
api 'com.google.guava:guava:27.0.1-android'
1516

catalog/java/io/material/catalog/transition/res/layout/cat_transition_fade_through_albums_fragment.xml

Lines changed: 30 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,36 @@
1414
~ See the License for the specific language governing permissions and
1515
~ limitations under the License.
1616
-->
17-
18-
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
17+
<androidx.gridlayout.widget.GridLayout
18+
xmlns:android="http://schemas.android.com/apk/res/android"
1919
xmlns:tools="http://schemas.android.com/tools"
2020
xmlns:app="http://schemas.android.com/apk/res-auto"
2121
android:id="@+id/albums_fragment"
2222
android:layout_width="match_parent"
2323
android:layout_height="match_parent"
2424
android:padding="4dp"
2525
android:clipToPadding="false"
26-
android:columnCount="2"
26+
app:columnCount="2"
27+
app:rowCount="3"
2728
android:gravity="center_horizontal"
28-
android:orientation="vertical"
29-
android:rowCount="3"
29+
app:orientation="vertical"
3030
tools:targetApi="lollipop">
3131

3232
<com.google.android.material.card.MaterialCardView
3333
android:layout_width="0dp"
3434
android:layout_height="0dp"
3535
android:layout_margin="4dp"
36-
android:layout_columnWeight="1"
37-
android:layout_rowWeight="1"
36+
app:layout_rowWeight="1"
37+
app:layout_columnWeight="1"
3838
android:clickable="true"
39-
android:focusable="true"
40-
android:minHeight="200dp"
41-
android:minWidth="200dp">
39+
android:focusable="true">
4240
<LinearLayout
4341
android:layout_width="match_parent"
4442
android:layout_height="wrap_content"
4543
android:orientation="vertical">
4644
<ImageView
4745
android:layout_width="match_parent"
48-
android:layout_height="118dp"
46+
android:layout_height="180dp"
4947
android:background="?attr/colorPrimary"
5048
android:contentDescription="@string/cat_transition_image_content_desc"
5149
app:srcCompat="@drawable/ic_components_24px"/>
@@ -72,19 +70,17 @@
7270
android:layout_width="0dp"
7371
android:layout_height="0dp"
7472
android:layout_margin="4dp"
75-
android:layout_columnWeight="1"
76-
android:layout_rowWeight="1"
73+
app:layout_rowWeight="1"
74+
app:layout_columnWeight="1"
7775
android:clickable="true"
78-
android:focusable="true"
79-
android:minHeight="200dp"
80-
android:minWidth="200dp">
76+
android:focusable="true">
8177
<LinearLayout
8278
android:layout_width="match_parent"
8379
android:layout_height="wrap_content"
8480
android:orientation="vertical">
8581
<ImageView
8682
android:layout_width="match_parent"
87-
android:layout_height="118dp"
83+
android:layout_height="180dp"
8884
android:background="?attr/colorPrimary"
8985
android:contentDescription="@string/cat_transition_image_content_desc"
9086
app:srcCompat="@drawable/ic_components_24px"/>
@@ -110,19 +106,17 @@
110106
android:layout_width="0dp"
111107
android:layout_height="0dp"
112108
android:layout_margin="4dp"
113-
android:layout_columnWeight="1"
114-
android:layout_rowWeight="1"
109+
app:layout_rowWeight="1"
110+
app:layout_columnWeight="1"
115111
android:clickable="true"
116-
android:focusable="true"
117-
android:minHeight="200dp"
118-
android:minWidth="200dp">
112+
android:focusable="true">
119113
<LinearLayout
120114
android:layout_width="match_parent"
121115
android:layout_height="wrap_content"
122116
android:orientation="vertical">
123117
<ImageView
124118
android:layout_width="match_parent"
125-
android:layout_height="118dp"
119+
android:layout_height="180dp"
126120
android:background="?attr/colorPrimary"
127121
android:contentDescription="@string/cat_transition_image_content_desc"
128122
app:srcCompat="@drawable/ic_components_24px"/>
@@ -149,19 +143,17 @@
149143
android:layout_width="0dp"
150144
android:layout_height="0dp"
151145
android:layout_margin="4dp"
152-
android:layout_columnWeight="1"
153-
android:layout_rowWeight="1"
146+
app:layout_rowWeight="1"
147+
app:layout_columnWeight="1"
154148
android:clickable="true"
155-
android:focusable="true"
156-
android:minHeight="200dp"
157-
android:minWidth="200dp">
149+
android:focusable="true">
158150
<LinearLayout
159151
android:layout_width="match_parent"
160152
android:layout_height="wrap_content"
161153
android:orientation="vertical">
162154
<ImageView
163155
android:layout_width="match_parent"
164-
android:layout_height="118dp"
156+
android:layout_height="180dp"
165157
android:background="?attr/colorPrimary"
166158
android:contentDescription="@string/cat_transition_image_content_desc"
167159
app:srcCompat="@drawable/ic_components_24px"/>
@@ -187,19 +179,17 @@
187179
android:layout_width="0dp"
188180
android:layout_height="0dp"
189181
android:layout_margin="4dp"
190-
android:layout_columnWeight="1"
191-
android:layout_rowWeight="1"
182+
app:layout_rowWeight="1"
183+
app:layout_columnWeight="1"
192184
android:clickable="true"
193-
android:focusable="true"
194-
android:minHeight="200dp"
195-
android:minWidth="200dp">
185+
android:focusable="true">
196186
<LinearLayout
197187
android:layout_width="match_parent"
198188
android:layout_height="wrap_content"
199189
android:orientation="vertical">
200190
<ImageView
201191
android:layout_width="match_parent"
202-
android:layout_height="118dp"
192+
android:layout_height="180dp"
203193
android:background="?attr/colorPrimary"
204194
android:contentDescription="@string/cat_transition_image_content_desc"
205195
app:srcCompat="@drawable/ic_components_24px"/>
@@ -226,19 +216,17 @@
226216
android:layout_width="0dp"
227217
android:layout_height="0dp"
228218
android:layout_margin="4dp"
229-
android:layout_columnWeight="1"
230-
android:layout_rowWeight="1"
219+
app:layout_rowWeight="1"
220+
app:layout_columnWeight="1"
231221
android:clickable="true"
232-
android:focusable="true"
233-
android:minHeight="200dp"
234-
android:minWidth="200dp">
222+
android:focusable="true">
235223
<LinearLayout
236224
android:layout_width="match_parent"
237225
android:layout_height="wrap_content"
238226
android:orientation="vertical">
239227
<ImageView
240228
android:layout_width="match_parent"
241-
android:layout_height="118dp"
229+
android:layout_height="180dp"
242230
android:background="?attr/colorPrimary"
243231
android:contentDescription="@string/cat_transition_image_content_desc"
244232
app:srcCompat="@drawable/ic_components_24px"/>
@@ -261,4 +249,4 @@
261249
</LinearLayout>
262250
</com.google.android.material.card.MaterialCardView>
263251

264-
</GridLayout>
252+
</androidx.gridlayout.widget.GridLayout>

catalog/java/io/material/catalog/transition/res/layout/cat_transition_fade_through_photos_fragment.xml

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,26 @@
1313
~ See the License for the specific language governing permissions and
1414
~ limitations under the License.
1515
-->
16-
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
16+
<androidx.gridlayout.widget.GridLayout
17+
xmlns:android="http://schemas.android.com/apk/res/android"
1718
xmlns:app="http://schemas.android.com/apk/res-auto"
1819
xmlns:tools="http://schemas.android.com/tools"
1920
android:id="@+id/photos_fragment"
2021
android:layout_width="match_parent"
2122
android:layout_height="match_parent"
2223
android:clipToPadding="false"
23-
android:columnCount="2"
24+
app:columnCount="2"
25+
app:rowCount="3"
2426
android:gravity="center_horizontal"
25-
android:orientation="vertical"
27+
app:orientation="vertical"
2628
android:padding="4dp"
27-
android:rowCount="3"
2829
tools:targetApi="lollipop">
2930

3031
<ImageView
3132
android:layout_width="0dp"
3233
android:layout_height="0dp"
33-
android:layout_rowWeight="1"
34-
android:layout_columnWeight="1"
34+
app:layout_rowWeight="1"
35+
app:layout_columnWeight="1"
3536
android:layout_margin="2dp"
3637
android:background="?attr/colorError"
3738
android:contentDescription="@string/cat_transition_image_content_desc"
@@ -40,8 +41,8 @@
4041
<ImageView
4142
android:layout_width="0dp"
4243
android:layout_height="0dp"
43-
android:layout_rowWeight="1"
44-
android:layout_columnWeight="1"
44+
app:layout_rowWeight="1"
45+
app:layout_columnWeight="1"
4546
android:layout_margin="2dp"
4647
android:background="?attr/colorError"
4748
android:contentDescription="@string/cat_transition_image_content_desc"
@@ -50,8 +51,8 @@
5051
<ImageView
5152
android:layout_width="0dp"
5253
android:layout_height="0dp"
53-
android:layout_rowWeight="1"
54-
android:layout_columnWeight="1"
54+
app:layout_rowWeight="1"
55+
app:layout_columnWeight="1"
5556
android:layout_margin="2dp"
5657
android:background="?attr/colorError"
5758
android:contentDescription="@string/cat_transition_image_content_desc"
@@ -60,8 +61,8 @@
6061
<ImageView
6162
android:layout_width="0dp"
6263
android:layout_height="0dp"
63-
android:layout_rowWeight="1"
64-
android:layout_columnWeight="1"
64+
app:layout_rowWeight="1"
65+
app:layout_columnWeight="1"
6566
android:layout_margin="2dp"
6667
android:background="?attr/colorError"
6768
android:contentDescription="@string/cat_transition_image_content_desc"
@@ -70,8 +71,8 @@
7071
<ImageView
7172
android:layout_width="0dp"
7273
android:layout_height="0dp"
73-
android:layout_rowWeight="1"
74-
android:layout_columnWeight="1"
74+
app:layout_rowWeight="1"
75+
app:layout_columnWeight="1"
7576
android:layout_margin="2dp"
7677
android:background="?attr/colorError"
7778
android:contentDescription="@string/cat_transition_image_content_desc"
@@ -80,10 +81,10 @@
8081
<ImageView
8182
android:layout_width="0dp"
8283
android:layout_height="0dp"
83-
android:layout_rowWeight="1"
84-
android:layout_columnWeight="1"
84+
app:layout_rowWeight="1"
85+
app:layout_columnWeight="1"
8586
android:layout_margin="2dp"
8687
android:background="?attr/colorError"
8788
android:contentDescription="@string/cat_transition_image_content_desc"
8889
app:srcCompat="@drawable/ic_components_24px" />
89-
</GridLayout>
90+
</androidx.gridlayout.widget.GridLayout>

catalog/java/io/material/catalog/transition/res/layout/cat_transition_fade_through_search_fragment.xml

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,27 @@
1313
~ See the License for the specific language governing permissions and
1414
~ limitations under the License.
1515
-->
16-
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
16+
<androidx.gridlayout.widget.GridLayout
17+
xmlns:android="http://schemas.android.com/apk/res/android"
1718
xmlns:app="http://schemas.android.com/apk/res-auto"
1819
xmlns:tools="http://schemas.android.com/tools"
1920
android:id="@+id/search_fragment"
2021
android:layout_width="match_parent"
2122
android:layout_height="match_parent"
2223
android:layout_weight="1"
2324
android:clipToPadding="false"
24-
android:columnCount="2"
25+
app:columnCount="2"
26+
app:rowCount="3"
2527
android:gravity="center_horizontal"
26-
android:orientation="vertical"
28+
app:orientation="vertical"
2729
android:padding="4dp"
28-
android:rowCount="3"
2930
tools:targetApi="lollipop">
3031

3132
<com.google.android.material.card.MaterialCardView
3233
android:layout_width="0dp"
3334
android:layout_height="0dp"
34-
android:layout_rowWeight="1"
35-
android:layout_columnWeight="1"
35+
app:layout_rowWeight="1"
36+
app:layout_columnWeight="1"
3637
android:layout_margin="4dp"
3738
android:clickable="true"
3839
android:focusable="true"
@@ -49,8 +50,8 @@
4950
<com.google.android.material.card.MaterialCardView
5051
android:layout_width="0dp"
5152
android:layout_height="0dp"
52-
android:layout_rowWeight="1"
53-
android:layout_columnWeight="1"
53+
app:layout_rowWeight="1"
54+
app:layout_columnWeight="1"
5455
android:layout_margin="4dp"
5556
android:clickable="true"
5657
android:focusable="true"
@@ -67,8 +68,8 @@
6768
<com.google.android.material.card.MaterialCardView
6869
android:layout_width="0dp"
6970
android:layout_height="0dp"
70-
android:layout_rowWeight="1"
71-
android:layout_columnWeight="1"
71+
app:layout_rowWeight="1"
72+
app:layout_columnWeight="1"
7273
android:layout_margin="4dp"
7374
android:clickable="true"
7475
android:focusable="true"
@@ -85,8 +86,8 @@
8586
<com.google.android.material.card.MaterialCardView
8687
android:layout_width="0dp"
8788
android:layout_height="0dp"
88-
android:layout_rowWeight="1"
89-
android:layout_columnWeight="1"
89+
app:layout_rowWeight="1"
90+
app:layout_columnWeight="1"
9091
android:layout_margin="4dp"
9192
android:clickable="true"
9293
android:focusable="true"
@@ -103,8 +104,8 @@
103104
<com.google.android.material.card.MaterialCardView
104105
android:layout_width="0dp"
105106
android:layout_height="0dp"
106-
android:layout_rowWeight="1"
107-
android:layout_columnWeight="1"
107+
app:layout_rowWeight="1"
108+
app:layout_columnWeight="1"
108109
android:layout_margin="4dp"
109110
android:clickable="true"
110111
android:focusable="true"
@@ -121,8 +122,8 @@
121122
<com.google.android.material.card.MaterialCardView
122123
android:layout_width="0dp"
123124
android:layout_height="0dp"
124-
android:layout_rowWeight="1"
125-
android:layout_columnWeight="1"
125+
app:layout_rowWeight="1"
126+
app:layout_columnWeight="1"
126127
android:layout_margin="4dp"
127128
android:clickable="true"
128129
android:focusable="true"
@@ -136,4 +137,4 @@
136137
app:srcCompat="@drawable/ic_search_24px" />
137138
</com.google.android.material.card.MaterialCardView>
138139

139-
</GridLayout>
140+
</androidx.gridlayout.widget.GridLayout>

0 commit comments

Comments
 (0)