Skip to content

Commit bc69c8b

Browse files
committed
Added the ability to override switch style.
In your app just create a style called overrideExpandableCardViewSwitch with your customizations
1 parent 33fb9de commit bc69c8b

10 files changed

Lines changed: 56 additions & 2 deletions

File tree

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item android:color="@color/colorAccentAtNightWhiteAtDay" android:state_checked="true" />
4+
<item android:color="@color/BlackWhiteColor" />
5+
</selector>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:shape="oval">
4+
5+
<solid android:color="@color/v3cometinswitchtint" />
6+
7+
<size
8+
android:width="12dp"
9+
android:height="12dp" />
10+
11+
<!-- results in the track looking smaller than the thumb -->
12+
<stroke
13+
android:width="8dp"
14+
android:color="@android:color/transparent" />
15+
</shape>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:shape="rectangle">
4+
<solid android:color="@android:color/transparent" />
5+
<corners android:radius="32dp" />
6+
7+
<!-- results in the track looking smaller than the thumb -->
8+
<stroke
9+
android:width="2.5dp"
10+
android:color="@color/v3cometinswitchtint" />
11+
</shape>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<color name="BlackWhiteColor">@color/white</color>
4+
<color name="colorAccentAtNightWhiteAtDay">@color/colorAccent</color>
5+
</resources>

app/src/main/res/values/colors.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,9 @@
33
<color name="colorPrimary">#1B37A5</color>
44
<color name="colorPrimaryDark">#1C339B</color>
55
<color name="colorAccent">#1976d2</color>
6+
<color name="white">@color/md_white_1000</color>
7+
<color name="md_white_1000">#ffffff</color>
8+
<color name="md_black_1000">#000000</color>
9+
<color name="BlackWhiteColor">@color/md_black_1000</color>
10+
<color name="colorAccentAtNightWhiteAtDay">@color/white</color>
611
</resources>

app/src/main/res/values/styles.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,12 @@
2323
<item name="android:layout_marginEnd">16dp</item>
2424
<item name="android:layout_marginTop">4dp</item>
2525
</style>
26+
27+
<style name="overrideExpandableCardViewSwitch">
28+
<item name="android:background">@null</item>
29+
<item name="android:padding">16dp</item>
30+
<item name="useMaterialThemeColors">false</item>
31+
<item name="android:thumb">@drawable/v3cometinswitchthumb</item>
32+
<item name="track">@drawable/v3cometinswitchtrack</item>
33+
</style>
2634
</resources>

expandablecardview/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ apply plugin: 'kotlin-android-extensions'
55
ext {
66
PUBLISH_GROUP_ID = 'host.stjin'
77
PUBLISH_ARTIFACT_ID = 'expandable-cardview'
8-
PUBLISH_VERSION = '1.2.2'
8+
PUBLISH_VERSION = '1.3.0-beta01'
99
}
1010

1111
android {

expandablecardview/src/main/res/layout/expandable_cardview.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555

5656
<com.google.android.material.switchmaterial.SwitchMaterial
5757
android:id="@+id/card_switch"
58+
style="@style/overrideExpandableCardViewSwitch"
5859
android:layout_width="wrap_content"
5960
android:layout_height="wrap_content"
6061
android:layout_marginEnd="8dp" />
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<style name="overrideExpandableCardViewSwitch" />
4+
</resources>

0 commit comments

Comments
 (0)