Skip to content

Commit dc69263

Browse files
committed
Update Catalog Button demo to use CoordinatorLayout, which enables Snackbar swipe to dismiss behavior
PiperOrigin-RevId: 260193185
1 parent 80b065c commit dc69263

File tree

1 file changed

+129
-123
lines changed

1 file changed

+129
-123
lines changed

catalog/java/io/material/catalog/button/res/layout/cat_buttons_fragment.xml

Lines changed: 129 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -15,133 +15,139 @@
1515
limitations under the License.
1616
-->
1717

18-
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
18+
<androidx.coordinatorlayout.widget.CoordinatorLayout
19+
xmlns:android="http://schemas.android.com/apk/res/android"
1920
xmlns:app="http://schemas.android.com/apk/res-auto"
2021
android:layout_width="match_parent"
2122
android:layout_height="match_parent">
2223

23-
<LinearLayout
24+
<ScrollView
2425
android:layout_width="match_parent"
25-
android:layout_height="wrap_content"
26-
android:orientation="vertical"
27-
android:paddingTop="16dp"
28-
android:paddingBottom="16dp"
29-
android:gravity="center_horizontal">
30-
31-
<TextView
32-
android:textStyle="bold"
33-
android:layout_width="wrap_content"
34-
android:layout_height="wrap_content"
35-
android:paddingTop="8dp"
36-
android:text="@string/cat_btn_text"
37-
android:textSize="16sp"/>
38-
39-
<Button
40-
android:id="@+id/material_button"
41-
android:layout_width="wrap_content"
42-
android:layout_height="wrap_content"
43-
android:text="@string/cat_button_label_enabled"/>
44-
45-
<TextView
46-
android:textStyle="bold"
47-
android:layout_width="wrap_content"
48-
android:layout_height="wrap_content"
49-
android:paddingTop="8dp"
50-
android:text="@string/cat_unelevated_btn_text"
51-
android:textSize="16sp"/>
52-
53-
<Button
54-
android:id="@+id/material_unelevated_button"
55-
style="@style/Widget.MaterialComponents.Button.UnelevatedButton"
56-
android:layout_width="wrap_content"
57-
android:layout_height="wrap_content"
58-
android:text="@string/cat_button_label_enabled"/>
26+
android:layout_height="match_parent">
5927

60-
<TextView
61-
android:textStyle="bold"
62-
android:layout_width="wrap_content"
63-
android:layout_height="wrap_content"
64-
android:paddingTop="8dp"
65-
android:text="@string/cat_icon_btn_text"
66-
android:textSize="16sp"/>
67-
68-
<Button
69-
android:id="@+id/material_icon_button"
70-
style="@style/Widget.MaterialComponents.Button.Icon"
71-
android:layout_width="wrap_content"
72-
android:layout_height="wrap_content"
73-
android:text="@string/cat_button_label_enabled"
74-
app:icon="@drawable/ic_dialogs_24px"/>
75-
76-
<TextView
77-
android:textStyle="bold"
78-
android:layout_width="wrap_content"
79-
android:layout_height="wrap_content"
80-
android:paddingTop="8dp"
81-
android:text="@string/cat_text_btn_text"
82-
android:textSize="16sp"/>
83-
84-
<Button
85-
android:id="@+id/material_text_button"
86-
style="@style/Widget.MaterialComponents.Button.TextButton"
87-
android:layout_width="wrap_content"
88-
android:layout_height="wrap_content"
89-
android:text="@string/cat_button_label_enabled"/>
90-
91-
<TextView
92-
android:textStyle="bold"
93-
android:layout_width="wrap_content"
94-
android:layout_height="wrap_content"
95-
android:paddingTop="8dp"
96-
android:text="@string/cat_icon_text_btn_text"
97-
android:textSize="16sp"/>
98-
99-
<Button
100-
android:id="@+id/material_icon_text_button"
101-
style="@style/Widget.MaterialComponents.Button.TextButton.Icon"
102-
android:layout_width="wrap_content"
103-
android:layout_height="wrap_content"
104-
android:text="@string/cat_button_label_enabled"
105-
app:icon="@drawable/ic_dialogs_24px"/>
106-
107-
<TextView
108-
android:textStyle="bold"
109-
android:layout_width="wrap_content"
110-
android:layout_height="wrap_content"
111-
android:paddingTop="8dp"
112-
android:text="@string/cat_outlined_btn_text"
113-
android:textSize="16sp"/>
114-
115-
<Button
116-
android:id="@+id/material_outlined_button"
117-
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
118-
android:layout_width="wrap_content"
119-
android:layout_height="wrap_content"
120-
android:text="@string/cat_button_label_enabled"/>
121-
122-
<TextView
123-
android:textStyle="bold"
124-
android:layout_width="wrap_content"
125-
android:layout_height="wrap_content"
126-
android:paddingTop="8dp"
127-
android:text="@string/cat_outlined_icon_btn_text"
128-
android:textSize="16sp"/>
129-
130-
<Button
131-
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
132-
android:layout_width="wrap_content"
133-
android:layout_height="wrap_content"
134-
android:contentDescription="@string/cat_button_icon_btn_text"
135-
app:icon="@drawable/ic_dialogs_24px"
136-
app:iconGravity="textStart"
137-
app:iconPadding="0dp"/>
138-
139-
<com.google.android.material.switchmaterial.SwitchMaterial
140-
android:id="@+id/cat_button_enabled_switch"
141-
android:layout_width="wrap_content"
28+
<LinearLayout
29+
android:layout_width="match_parent"
14230
android:layout_height="wrap_content"
143-
android:layout_marginTop="16dp"
144-
android:text="@string/cat_button_label_enabled"
145-
android:checked="true"/>
146-
</LinearLayout>
147-
</ScrollView>
31+
android:paddingTop="16dp"
32+
android:paddingBottom="16dp"
33+
android:gravity="center_horizontal"
34+
android:orientation="vertical">
35+
36+
<TextView
37+
android:textStyle="bold"
38+
android:layout_width="wrap_content"
39+
android:layout_height="wrap_content"
40+
android:paddingTop="8dp"
41+
android:text="@string/cat_btn_text"
42+
android:textSize="16sp"/>
43+
44+
<Button
45+
android:id="@+id/material_button"
46+
android:layout_width="wrap_content"
47+
android:layout_height="wrap_content"
48+
android:text="@string/cat_button_label_enabled"/>
49+
50+
<TextView
51+
android:textStyle="bold"
52+
android:layout_width="wrap_content"
53+
android:layout_height="wrap_content"
54+
android:paddingTop="8dp"
55+
android:text="@string/cat_unelevated_btn_text"
56+
android:textSize="16sp"/>
57+
58+
<Button
59+
android:id="@+id/material_unelevated_button"
60+
style="@style/Widget.MaterialComponents.Button.UnelevatedButton"
61+
android:layout_width="wrap_content"
62+
android:layout_height="wrap_content"
63+
android:text="@string/cat_button_label_enabled"/>
64+
65+
<TextView
66+
android:textStyle="bold"
67+
android:layout_width="wrap_content"
68+
android:layout_height="wrap_content"
69+
android:paddingTop="8dp"
70+
android:text="@string/cat_icon_btn_text"
71+
android:textSize="16sp"/>
72+
73+
<Button
74+
android:id="@+id/material_icon_button"
75+
style="@style/Widget.MaterialComponents.Button.Icon"
76+
android:layout_width="wrap_content"
77+
android:layout_height="wrap_content"
78+
android:text="@string/cat_button_label_enabled"
79+
app:icon="@drawable/ic_dialogs_24px"/>
80+
81+
<TextView
82+
android:textStyle="bold"
83+
android:layout_width="wrap_content"
84+
android:layout_height="wrap_content"
85+
android:paddingTop="8dp"
86+
android:text="@string/cat_text_btn_text"
87+
android:textSize="16sp"/>
88+
89+
<Button
90+
android:id="@+id/material_text_button"
91+
style="@style/Widget.MaterialComponents.Button.TextButton"
92+
android:layout_width="wrap_content"
93+
android:layout_height="wrap_content"
94+
android:text="@string/cat_button_label_enabled"/>
95+
96+
<TextView
97+
android:textStyle="bold"
98+
android:layout_width="wrap_content"
99+
android:layout_height="wrap_content"
100+
android:paddingTop="8dp"
101+
android:text="@string/cat_icon_text_btn_text"
102+
android:textSize="16sp"/>
103+
104+
<Button
105+
android:id="@+id/material_icon_text_button"
106+
style="@style/Widget.MaterialComponents.Button.TextButton.Icon"
107+
android:layout_width="wrap_content"
108+
android:layout_height="wrap_content"
109+
android:text="@string/cat_button_label_enabled"
110+
app:icon="@drawable/ic_dialogs_24px"/>
111+
112+
<TextView
113+
android:textStyle="bold"
114+
android:layout_width="wrap_content"
115+
android:layout_height="wrap_content"
116+
android:paddingTop="8dp"
117+
android:text="@string/cat_outlined_btn_text"
118+
android:textSize="16sp"/>
119+
120+
<Button
121+
android:id="@+id/material_outlined_button"
122+
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
123+
android:layout_width="wrap_content"
124+
android:layout_height="wrap_content"
125+
android:text="@string/cat_button_label_enabled"/>
126+
127+
<TextView
128+
android:textStyle="bold"
129+
android:layout_width="wrap_content"
130+
android:layout_height="wrap_content"
131+
android:paddingTop="8dp"
132+
android:text="@string/cat_outlined_icon_btn_text"
133+
android:textSize="16sp"/>
134+
135+
<Button
136+
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
137+
android:layout_width="wrap_content"
138+
android:layout_height="wrap_content"
139+
android:contentDescription="@string/cat_button_icon_btn_text"
140+
app:icon="@drawable/ic_dialogs_24px"
141+
app:iconGravity="textStart"
142+
app:iconPadding="0dp"/>
143+
144+
<com.google.android.material.switchmaterial.SwitchMaterial
145+
android:id="@+id/cat_button_enabled_switch"
146+
android:layout_width="wrap_content"
147+
android:layout_height="wrap_content"
148+
android:layout_marginTop="16dp"
149+
android:checked="true"
150+
android:text="@string/cat_button_label_enabled"/>
151+
</LinearLayout>
152+
</ScrollView>
153+
</androidx.coordinatorlayout.widget.CoordinatorLayout>

0 commit comments

Comments
 (0)