728x90
반응형
<com.google.android.material.switchmaterial.SwitchMaterial
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:useMaterialThemeColors="false"
app:switchMinWidth="40dp"
app:track="@drawable/switch_track_selector"
android:thumb="@drawable/switch_thumb_selector"
/>
switch_thumb_selector
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
>
<!-- 스위치의 배경-->
<item
android:drawable="@drawable/switch_thumb_off"
android:state_checked="false"/>
<item
android:drawable="@drawable/switch_thumb_on"
android:state_checked="true"/>
</selector>
switch_thumb_on
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
android:dither="true"
android:useLevel="false"
>
<solid android:color="#ffffff" />
<stroke
android:width="2dp"
android:color="#00FF2B"/>
<size android:width="22dp"
android:height="22dp"/>
</shape>
switch_thumb_off
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
android:dither="true"
android:useLevel="false"
>
<solid android:color="#ffffff" />
<stroke
android:width="2dp"
android:color="#dfdfdf"/>
<size android:width="22dp"
android:height="22dp"/>
</shape>
switch_track_selector
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 스위치의 배경-->
<item
android:drawable="@drawable/switch_track_off"
android:state_checked="false"/>
<item
android:drawable="@drawable/switch_track_on"
android:state_checked="true"/>
</selector>
switch_track_off
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"
android:dither="true"
android:useLevel="false"
>
<solid android:color="#ffffff" />
<stroke
android:width="2dp"
android:color="#dfdfdf"/>
<size android:width="22dp"
android:height="22dp"/>
</shape>
switch_track_on
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners
android:radius="15dp" />
<!-- 트랙의 width / height
사실 width는 위젯 속성 중 'app:switchMinWidth'에 의해 설정되므로 크게 상관은 없습니다. -->
<size
android:width="40dp"
android:height="20dp" />
<solid
android:color="#00FF2B" />
</shape>
728x90
반응형
'Android' 카테고리의 다른 글
Android AudioRecode PCM to wav (0) | 2024.02.19 |
---|---|
android.hardware.usb.action.USB_ACCESSORY_ATTACHED (0) | 2024.01.23 |
Android cutout 영역 ( IOS의 노치 영역 ) (0) | 2023.09.06 |
Android AsyncTask => RxJava (0) | 2023.09.05 |
Android System Font Scale 수정하기 (0) | 2023.08.29 |