Skip to content

Commit 123e130

Browse files
author
piclabsstudio
committed
Update Widgets
1 parent 37e6536 commit 123e130

File tree

5 files changed

+998
-0
lines changed

5 files changed

+998
-0
lines changed

app/src/main/java/com/dvinfosys/WidgetsExample/Activity/HomeActivity.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.dvinfosys.WidgetsExample.Fragments.ProgressViewFragment;
2424
import com.dvinfosys.WidgetsExample.Fragments.RadioButtonFragment;
2525
import com.dvinfosys.WidgetsExample.Fragments.SeekbarFragment;
26+
import com.dvinfosys.WidgetsExample.Fragments.SwitchFragment;
2627
import com.dvinfosys.WidgetsExample.Fragments.TextViewFragment;
2728
import com.dvinfosys.WidgetsExample.Fragments.ToastViewFragment;
2829
import com.dvinfosys.WidgetsExample.Fragments.VPVideoPlayerFragment;
@@ -113,6 +114,8 @@ public boolean onNavigationItemSelected(MenuItem item) {
113114
fragment = new NumberCounterFragment();
114115
} else if (id == R.id.nav_color_picker) {
115116
fragment = new ColorPickerFragment();
117+
} else if (id == R.id.nav_switch) {
118+
fragment = new SwitchFragment();
116119
} else if (id == R.id.nav_share) {
117120

118121
} else if (id == R.id.nav_send) {
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.dvinfosys.WidgetsExample.Fragments;
2+
3+
4+
import android.os.Bundle;
5+
import android.support.v4.app.Fragment;
6+
import android.view.LayoutInflater;
7+
import android.view.View;
8+
import android.view.ViewGroup;
9+
10+
import com.dvinfosys.WidgetsExample.R;
11+
import com.dvinfosys.widgets.Switch.SwitchButton;
12+
13+
public class SwitchFragment extends Fragment {
14+
15+
@Override
16+
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
17+
View view = inflater.inflate(R.layout.fragment_switch, container, false);
18+
SwitchButton switchButton = view.findViewById(R.id.switch_button);
19+
20+
switchButton.setChecked(false);
21+
switchButton.isChecked();
22+
switchButton.toggle(); //switch state
23+
switchButton.toggle(false);//switch without animation
24+
switchButton.setShadowEffect(true);//disable shadow effect
25+
switchButton.setEnabled(false);//disable button
26+
switchButton.setEnableEffect(false);//disable the switch animation
27+
switchButton.setOnCheckedChangeListener(new SwitchButton.OnCheckedChangeListener() {
28+
@Override
29+
public void onCheckedChanged(SwitchButton view, boolean isChecked) {
30+
//TODO do your job
31+
}
32+
});
33+
34+
35+
return view;
36+
}
37+
38+
}
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
android:orientation="vertical"
8+
tools:context=".Fragments.SwitchFragment">
9+
10+
<LinearLayout
11+
android:layout_width="match_parent"
12+
android:layout_height="match_parent"
13+
android:gravity="center"
14+
android:orientation="vertical">
15+
16+
<com.dvinfosys.widgets.Switch.SwitchButton
17+
android:id="@+id/switch_button"
18+
android:layout_width="wrap_content"
19+
android:layout_height="wrap_content"
20+
android:layout_gravity="center"
21+
android:layout_marginTop="10dp" />
22+
23+
<com.dvinfosys.widgets.Switch.SwitchButton
24+
android:layout_width="wrap_content"
25+
android:layout_height="wrap_content"
26+
android:layout_marginTop="10dp"
27+
app:sb_checked="true" />
28+
29+
<com.dvinfosys.widgets.Switch.SwitchButton
30+
android:layout_width="wrap_content"
31+
android:layout_height="wrap_content"
32+
android:layout_marginTop="10dp"
33+
app:sb_checked="true"
34+
app:show_indicator="false" />
35+
36+
<com.dvinfosys.widgets.Switch.SwitchButton
37+
android:layout_width="wrap_content"
38+
android:layout_height="wrap_content"
39+
android:layout_marginTop="10dp"
40+
app:sb_checked="true"
41+
app:sb_checked_color="#fdc951" />
42+
43+
<com.dvinfosys.widgets.Switch.SwitchButton
44+
android:layout_width="wrap_content"
45+
android:layout_height="wrap_content"
46+
android:layout_marginTop="10dp"
47+
app:sb_background="#FFF"
48+
app:sb_button_color="#db99c7"
49+
app:sb_checked_color="#A36F95"
50+
app:sb_checkline_color="#a5dc88"
51+
app:sb_shadow_color="#A36F95"
52+
app:sb_uncheckcircle_color="#A36F95" />
53+
54+
<com.dvinfosys.widgets.Switch.SwitchButton
55+
android:layout_width="wrap_content"
56+
android:layout_height="wrap_content"
57+
android:layout_marginTop="10dp"
58+
app:sb_enable_effect="false" />
59+
60+
<com.dvinfosys.widgets.Switch.NormalSwitch
61+
android:layout_width="wrap_content"
62+
android:layout_height="wrap_content"
63+
android:layout_gravity="center"
64+
android:layout_margin="8dp"
65+
android:text="Normal Switch"
66+
android:textAllCaps="false" />
67+
68+
<com.dvinfosys.widgets.Switch.HeadingSwitch
69+
android:layout_width="wrap_content"
70+
android:layout_height="wrap_content"
71+
android:layout_gravity="center"
72+
android:layout_margin="8dp"
73+
android:text="heading Switch"
74+
android:textAllCaps="false" />
75+
76+
<com.dvinfosys.widgets.Switch.BlackSwitch
77+
android:layout_width="wrap_content"
78+
android:layout_height="wrap_content"
79+
android:layout_gravity="center"
80+
android:layout_margin="8dp"
81+
android:text="Black Switch"
82+
android:textAllCaps="false" />
83+
84+
<com.dvinfosys.widgets.Switch.ExtraBoldSwitch
85+
android:layout_width="wrap_content"
86+
android:layout_height="wrap_content"
87+
android:layout_gravity="center"
88+
android:layout_margin="8dp"
89+
android:text="ExtraBold Switch"
90+
android:textAllCaps="false" />
91+
92+
<com.dvinfosys.widgets.Switch.ItalicSwitch
93+
android:layout_width="wrap_content"
94+
android:layout_height="wrap_content"
95+
android:layout_gravity="center"
96+
android:layout_margin="8dp"
97+
android:text="Italic Switch"
98+
android:textAllCaps="false" />
99+
100+
<com.dvinfosys.widgets.Switch.LightSwitch
101+
android:layout_width="wrap_content"
102+
android:layout_height="wrap_content"
103+
android:layout_gravity="center"
104+
android:layout_margin="8dp"
105+
android:text="Light Switch"
106+
android:textAllCaps="false" />
107+
108+
<com.dvinfosys.widgets.Switch.SemiBoldSwitch
109+
android:layout_width="wrap_content"
110+
android:layout_height="wrap_content"
111+
android:layout_gravity="center"
112+
android:layout_margin="8dp"
113+
android:text="SemiBold Switch"
114+
android:textAllCaps="false" />
115+
116+
<com.dvinfosys.widgets.Switch.ThinSwitch
117+
android:layout_width="wrap_content"
118+
android:layout_height="wrap_content"
119+
android:layout_gravity="center"
120+
android:layout_margin="8dp"
121+
android:text="Thin Switch"
122+
android:textAllCaps="false" />
123+
124+
</LinearLayout>
125+
126+
</ScrollView>

0 commit comments

Comments
 (0)