Skip to content

Commit 231bb3e

Browse files
committed
Update readme
1 parent 224dfdd commit 231bb3e

1 file changed

Lines changed: 113 additions & 12 deletions

File tree

README.md

Lines changed: 113 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,132 @@ Slide button library for android, we hope this library is useful and easy to cus
99

1010
# Gradle
1111

12+
Add **dependencies** to your `build.gradle` file at `:app` or modules level
13+
1214
```groovy
13-
...
14-
dependencies {
15-
16-
implementation 'id.ss564.lib.slidingbutton:slidingbutton:<latest-version>'
17-
18-
}
19-
...
15+
implementation 'id.ss564.lib.slidingbutton:slidingbutton:<latest-version>'
2016
```
2117

18+
Then **sync** your gradle. If you have errors, try to add maven url to your `build.gradle` project level
2219

20+
```groovy
21+
repositories {
22+
...
23+
maven { url 'https://dl.bintray.com/ss564/SlidingButton' }
24+
...
25+
}
26+
```
2327

2428

2529

2630
# How To Use
27-
In your layout.xml file, add this view
31+
> **Notes** : This guide is still in process, I will work on it as soon as possible. So, keep checking later if you see this note.
32+
33+
34+
35+
In your *layout.xml* file, add the view
2836

2937
```xml
3038
<id.ss564.lib.slidingbutton.SlidingButton
31-
android:id="@+id/slidingButton"
32-
android:layout_width="match_parent"
33-
android:layout_height="wrap_content"
34-
/>
39+
android:id="@+id/slidingButton"
40+
android:layout_width="match_parent"
41+
android:layout_height="wrap_content"/>
3542
```
3643

44+
Yeah... just add like code above. It's pretty simple :smile:
45+
46+
You can use `SlidingButton.OnStatusChangeListener` to find out if the button is shifted or not. Just add a little bit code like below on your `java` or `kotlin` file, for example on **MainActivity**
47+
48+
- Java
49+
50+
```java
51+
public class MainActivity extend AppCompatActivty {
52+
53+
@Override
54+
protected void onCreate(Bundle savedInstanceState){
55+
super.onCreate(savedInstanceState);
56+
setContentView(R.layout.activity_main);
57+
58+
SlidingButton mSlidingButton = findViewById(R.id.slidingButton);
59+
mSlidingButton.setOnStatusChangeListener(new SlidingButton.OnStatusChangeListener(){
60+
61+
@Override
62+
public void onStatusChange(boolean active){
63+
//do what you wanna to do
64+
}
65+
})
66+
}
67+
}
68+
```
69+
70+
71+
- Kotlin
72+
73+
```kotlin
74+
class MainActivity : AppCompatActivity() {
75+
76+
override fun onCreate(savedInstanceState : Bundle?){
77+
super.onCreate(savedInstanceState)
78+
setContentView(R.layout.activity_main)
79+
80+
//access view using synthetic, do your own style to access the view :)
81+
slidingButton.setOnStatusChangeListener { active ->
82+
//or using `object : SlidingButton.OnStatusChangeListener` instead of lambda
83+
84+
//do what you wanna to do
85+
}
86+
}
87+
}
88+
```
89+
90+
It's pretty simple right? :smile:
91+
92+
93+
94+
If you wanna customizing, please attention to the following attributes:
95+
96+
- `app:sliding_text`
97+
98+
Use to set text to the view, value of this attribute is *string* that can be **hardcode**, **reference**,or **null**
99+
100+
- `app:sliding_text_color`
101+
102+
Use to set text color, value of this attribute can be **hardcode** or **reference**. Absolutely you can reference it to *ColorStateList* :smile:
103+
104+
- `app:sliding_text_size`
105+
106+
Use to set text size, value of this attribute is *dimension* that can be **hardcode** or **reference**
107+
108+
- `app:sliding_text_fontFamily`
109+
110+
Use to set font family by name, value of this attribute is *string* that can be **hardcode**, or **reference**
111+
112+
- `app:sliding_text_textStyle`
113+
114+
Use to set text style, value of this attribute `normal`, `italic`,`bold`, or `bold|italic`
115+
116+
- `app:sliding_text_background`
117+
118+
Use to set text background, value of this attribute can be **color**, **drawable**, or **null**. Absolutely you can reference it to *ColorStateList* or *StateListDrawable* :smile:
119+
120+
- `app:sliding_text_paddingStart`, `app:sliding_text_paddingTop`, `app:sliding_text_paddingEnd`, `app:sliding_text_paddingBottom`
121+
122+
Use to set text padding, value is *dimension* that can be **hardcode** or **reference**
123+
124+
- `app:sliding_button_width`, `app:sliding_button_height`
125+
126+
- `app:sliding_button_icon`
127+
128+
- `app:sliding_button_icon_tint`
129+
130+
- `app:sliding_icon_scaleType`
131+
132+
- `app:sliding_button_background`
133+
134+
- `app:sliding_button_paddingStart`, `app:sliding_button_paddingTop`, `app:sliding_button_paddingEnd`, `app:sliding_button_paddingBottom`
135+
136+
- `app:sliding_button_marginStart`, `app:sliding_button_marginTop`, `app:sliding_button_marginEnd`, `app:sliding_button_marginBottom`
137+
37138

38139

39140

0 commit comments

Comments
 (0)