Skip to content

Commit

Permalink
[f] Add custom checked value in layout properties
Browse files Browse the repository at this point in the history
  • Loading branch information
luongvo committed Mar 13, 2017
1 parent 5188524 commit 88b4f55
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<vn.luongvo.widget.iosswitchview.SwitchView
android:layout_width="50dp"
android:layout_height="wrap_content"
app:checked="true"
app:color_off="#e13a8e"
app:color_on="#ef5e43" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ private void init(AttributeSet attrs) {
try {
colorOn = a.getColor(R.styleable.app_color_on, DEFAULT_COLOR_ON);
colorOff = a.getColor(R.styleable.app_color_off, DEFAULT_COLOR_OFF);
isChecked = a.getBoolean(R.styleable.app_checked, false);

state = isChecked ? STATE_SWITCH_ON : STATE_SWITCH_OFF;
} finally {
a.recycle();
}
Expand Down
1 change: 1 addition & 0 deletions library/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<resources>
<declare-styleable name="app">
<attr name="checked" format="boolean" />
<attr name="color_on" format="color" />
<attr name="color_off" format="color" />
</declare-styleable>
Expand Down

0 comments on commit 88b4f55

Please sign in to comment.