Skip to content

Commit 229eb9d

Browse files
dsn5ftdrchen
authored andcommitted
[Catalog] Update Catalog preferences demo to use MaterialSwitch
Related to #2828 PiperOrigin-RevId: 464830220
1 parent 5c6f0c8 commit 229eb9d

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (C) 2022 The Android Open Source Project
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
18+
<!-- Layout used by SwitchPreference for the switch widget style. This is inflated
19+
inside android.R.layout.preference. -->
20+
<com.google.android.material.materialswitch.MaterialSwitch
21+
xmlns:android="http://schemas.android.com/apk/res/android"
22+
android:id="@+id/switchWidget"
23+
android:layout_width="wrap_content"
24+
android:layout_height="wrap_content"
25+
android:focusable="false"
26+
android:clickable="false"
27+
android:background="@null"/>

catalog/java/io/material/catalog/application/theme/res/values/themes.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<resources xmlns:tools="http://schemas.android.com/tools">
1818

1919
<style name="Theme.Catalog" parent="Theme.Material3.DayNight.NoActionBar">
20+
<item name="preferenceTheme">@style/CatalogPreferenceThemeOverlay</item>
2021
<item name="catalogToolbarStyle">@style/Widget.Catalog.Toolbar</item>
2122
<item name="catalogToolbarWithCloseButtonStyle">@style/Widget.Catalog.Toolbar.WithCloseButton</item>
2223
<item name="textInputSignInStyle">@style/Widget.Material3.TextInputLayout.OutlinedBox</item>
@@ -28,4 +29,12 @@
2829
<item name="android:statusBarColor" tools:targetApi="21">@android:color/transparent</item>
2930
</style>
3031

32+
<style name="CatalogPreferenceThemeOverlay" parent="PreferenceThemeOverlay">
33+
<item name="switchPreferenceCompatStyle">@style/Preference.SwitchPreferenceCompat.Catalog</item>
34+
</style>
35+
36+
<style name="Preference.SwitchPreferenceCompat.Catalog" parent="Preference.SwitchPreferenceCompat.Material">
37+
<item name="android:widgetLayout">@layout/preference_widget_material_switch</item>
38+
</style>
39+
3140
</resources>

0 commit comments

Comments
 (0)