瀏覽代碼

[공통][New] OnOffSwitch - 커스텀 스위치 위젯 추가

hyodong.min 7 年之前
父節點
當前提交
d2e00c499b

+ 3 - 4
app/src/main/java/kr/co/zumo/app/lifeplus/view/custom/OnOffSwitch.java

@@ -27,18 +27,17 @@ public class OnOffSwitch extends Switch {
   protected CompoundButton.OnCheckedChangeListener onCheckedChangeListener;
 
   public OnOffSwitch(Context context) {
-    super(context);
-//    super(context, null, R.style.OnOffSwitch);
+    super(context, null, R.attr.customSwitchStyle);
     init();
   }
 
   public OnOffSwitch(Context context, AttributeSet attrs) {
-    super(context, attrs);
+    super(context, attrs, R.attr.customSwitchStyle);
     init();
   }
 
   public OnOffSwitch(Context context, AttributeSet attrs, int defStyleAttr) {
-    super(context, attrs, defStyleAttr);
+    super(context, attrs, R.attr.customSwitchStyle);
     init();
   }
 

+ 0 - 1
app/src/main/res/layout/setting_custom_menu1.xml

@@ -133,7 +133,6 @@
           android:layout_alignParentEnd="true"
           android:layout_marginTop="48dp"
           android:layout_marginBottom="28dp"
-          style="@style/OnOffSwitch"
           />
 
       </RelativeLayout>

+ 6 - 1
app/src/main/res/values/attrs.xml

@@ -2,4 +2,9 @@
 <resources>
   <declare-styleable name="BenefitView">
   </declare-styleable>
-</resources>
+
+  <!-- Switch 에 스타일을 적용하기 위한 레퍼런스 속성 -->
+  <declare-styleable name="CustomTheme">
+  <attr name="customSwitchStyle" format="reference"/>
+</declare-styleable>
+</resources>

+ 3 - 0
app/src/main/res/values/styles.xml

@@ -19,6 +19,7 @@
     <item name="android:windowContentOverlay">@null</item>
     <!--<item name="android:windowFullscreen">true</item>-->
     <!--<item name="android:fontFamily">@font/font1</item>--> <!-- Toast 에 적용이 안된다. -->
+    <item name="customSwitchStyle">@style/OnOffSwitch</item>
   </style>
 
   <style name="FullScreenDialog" parent="Theme.AppCompat.Light.Dialog">
@@ -68,5 +69,7 @@
     <item name="android:switchMinWidth">46dp</item>
     <item name="android:thumb">@drawable/switch_thumb_selector</item>
     <item name="android:background">@drawable/switch_track_selector</item>
+    <item name="android:textOff">""</item>
+    <item name="android:textOn">""</item>
   </style>
 </resources>