Skip to content

Commit ffa864e

Browse files
committed
Update README
1 parent b860c72 commit ffa864e

File tree

3 files changed

+82
-46
lines changed

3 files changed

+82
-46
lines changed

README.md

Lines changed: 79 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,42 @@
11
<h1> Sigmapoint Custom Button </h1>
22

3-
<p> This button can help you to faster create button with background drawable, text color state, image inside button,
4-
you only must specify colors, position, drawables, etc in xml button tags.</p>
53
<p> If you want start use this button, you must clone or download this repository. Next in Android Studio File -> New -> Import module.
64
Then select library folder from project. And start use. </p>
75
<p> >=API 8 </p>
86

7+
<h2> Features </h2>
8+
9+
* Use only custom tags in button declaration and reach state colors of text, background, frame and drawable.
10+
* Add only one image and change it color dynamically
11+
* Text color for normal, pressed and disabled state
12+
* Background color for normal, pressed and disabled state
13+
* Frame color for normal, pressed and disabled state
14+
* Drawable color for normal, pressed and disabled state
15+
* Specify image position and text will be centered with relation to whole button
16+
17+
See below to example:
18+
19+
image
20+
21+
For creating facebook button you must only do this:
22+
```xml
23+
<pl.sigmapoint.customview.CustomButton
24+
android:layout_width="match_parent"
25+
android:layout_height="0dp"
26+
android:layout_weight="5"
27+
android:text="Log in with facebook"
28+
app:cb_image="@drawable/ic_facebook"
29+
app:cb_image_color_disabled="#c0c0c0"
30+
app:cb_image_color_normal="#FFFFFF"
31+
app:cb_image_color_pressed="#c4cde0"
32+
app:cb_image_padding="5dp"
33+
app:cb_image_position="left"
34+
app:cb_primary_color="#3B5998"
35+
app:cb_secondary_color="#17233c"
36+
app:cb_shape_radius="5dp"
37+
app:cb_text_color="#FFFFFF" />
38+
```
39+
940
<h2> Reference </h2>
1041
<p> Default image position is left and centered text in button. When image is bigger than half of width, weight automatically is setting to 1. <br>
1142
Only when image is in horizontal position text can be center. </p>
@@ -19,52 +50,52 @@ This is the base tag of CustomButton:<br>
1950
android:layout_height="match_parent"
2051
android:text="text"/>
2152
```
22-
<p> You can specify the following things:
23-
cb_primary_color - \/
24-
cb_secondary_color - you can specify only two colors for all button. But it will be override by background, text, frame color. {format - color} <br>
25-
cb_background - background color of normal button {format - color} <br>
26-
cb_background_pressed - background color of pressed button {format - color} <br>
27-
cb_background_disabled - background color of disabled button {format - color} <br>
28-
cb_background_state_list - {format - ColorStateList} <br>
53+
<p> You can specify the following things: <br>
54+
`cb_primary_color` - you can specify only two colors for all button. But it will be override by background, text, frame color. {format - color} <br>
55+
`cb_secondary_color` - you can specify only two colors for all button. But it will be override by background, text, frame color. {format - color} <br>
56+
`cb_background` - background color of normal button {format - color} <br>
57+
`cb_background_pressed` - background color of pressed button {format - color} <br>
58+
`cb_background_disabled` - background color of disabled button {format - color} <br>
59+
`cb_background_state_list` - {format - ColorStateList} <br>
2960
<br>
30-
cb_text_color_pressed - color of pressed text {format - color} <br>
31-
cb_text_color_disabled - color of disabled text {format - color} <br>
32-
cb_text_color or android:textColor - color of normal text {format - color} <br>
33-
cb_text_size - {format - dimension} <br>
34-
cb_text_padding - {format - dimension} <br>
35-
cb_text_padding_left - {format - dimension} <br>
36-
cb_text_padding_top - {format - dimension} <br>
37-
cb_text_padding_right - {format - dimension} <br>
38-
cb_text_padding_bottom - {format - dimension} <br>
39-
cb_text_weight - {format - integer} <br>
40-
cb_text_center or android:textAlignment - only works when image weight doesn't specify. Center text in button. {format - boolean or only "center" value} <br>
61+
`cb_text_color_pressed` - color of pressed text {format - color} <br>
62+
`cb_text_color_disabled` - color of disabled text {format - color} <br>
63+
`cb_text_color` or `android:textColor` - color of normal text {format - color} <br>
64+
`cb_text_size` - {format - dimension} <br>
65+
`cb_text_padding` - {format - dimension} <br>
66+
`cb_text_padding_left` - {format - dimension} <br>
67+
`cb_text_padding_top` - {format - dimension} <br>
68+
`cb_text_padding_right` - {format - dimension} <br>
69+
`cb_text_padding_bottom` - {format - dimension} <br>
70+
`cb_text_weight` - {format - integer} <br>
71+
`cb_text_center` or `android:textAlignment` - only works when image weight doesn't specify. Center text in button. {format - boolean or only "center" value} <br>
4172
<br>
42-
cb_shape_radius - corner radius {format - dimension}<br>
43-
cb_shape_type - shape type, you can choose: rect or oval <br>
44-
cb_frame_color - {format - color} <br>
45-
cb_frame_color_pressed - {format - color} <br>
46-
cb_frame_color_disabled - {format - color} <br>
47-
cb_frame_size - frame height {format - dimension} <br>
48-
cb_frame_state_list - {format - ColorStateList} <br>
73+
`cb_shape_radius` - corner radius {format - dimension}<br>
74+
`cb_shape_type` - shape type, you can choose: rect or oval <br>
75+
`cb_frame_color` - {format - color} <br>
76+
`cb_frame_color_pressed` - {format - color} <br>
77+
`cb_frame_color_disabled` - {format - color} <br>
78+
`cb_frame_size` - frame height {format - dimension} <br>
79+
`cb_frame_state_list` - {format - ColorStateList} <br>
4980
<br>
50-
cb_elevation_enabled - on >=API 21 devices enable elvation (default) {format - boolean} <br>
81+
`cb_elevation_enabled` - on >=API 21 devices enable elvation (default) {format - boolean} <br>
5182
<br>
52-
cb_image_position - image position in button, can choose left, top, right, bottom <br>
53-
cb_image - image source {format - drawable or color} <br>
54-
cb_image_normal - normal state image source (if you choose cb_image, it will be override) {format - drawable or color} <br>
55-
cb_image_disabled - disabled state image source (if you choose cb_image, it will be override) {format - drawable or color} <br>
56-
cb_image_pressed - pressed state image source (if you choose cb_image, it will be override) {format - drawable or color} <br>
57-
cb_image_color_normal - only for image {format - color} <br>
58-
cb_image_color_pressed - only for image {format - color} <br>
59-
cb_image_color_disable - only for image {format - color} <br>
60-
cb_image_color_list - only for image {format - colorStateList} <br>
61-
cb_image_padding - {format - dimension} <br>
62-
cb_image_padding_left - {format - dimension} <br>
63-
cb_image_padding_top - {format - dimension} <br>
64-
cb_image_padding_right - {format - dimension} <br>
65-
cb_image_padding_bottom - {format - dimension} <br>
66-
cb_image_scale_type - {center, center_inside, center_crop, fit_center, fit_start, fit_end, fit_xy} <br>
67-
cb_image_weight - {format - integer} </p>
83+
`cb_image_position` - image position in button, can choose left, top, right, bottom <br>
84+
`cb_image` - image source {format - drawable or color} <br>
85+
`cb_image_normal` - normal state image source (if you choose cb_image, it will be override) {format - drawable or color} <br>
86+
`cb_image_disabled` - disabled state image source (if you choose cb_image, it will be override) {format - drawable or color} <br>
87+
`cb_image_pressed` - pressed state image source (if you choose cb_image, it will be override) {format - drawable or color} <br>
88+
`cb_image_color_normal` - only for image {format - color} <br>
89+
`cb_image_color_pressed` - only for image {format - color} <br>
90+
`cb_image_color_disable` - only for image {format - color} <br>
91+
`cb_image_color_list` - only for image {format - colorStateList} <br>
92+
`cb_image_padding` - {format - dimension} <br>
93+
`cb_image_padding_left` - {format - dimension} <br>
94+
`cb_image_padding_top` - {format - dimension} <br>
95+
`cb_image_padding_right` - {format - dimension} <br>
96+
`cb_image_padding_bottom` - {format - dimension} <br>
97+
`cb_image_scale_type` - {center, center_inside, center_crop, fit_center, fit_start, fit_end, fit_xy} <br>
98+
`cb_image_weight` - {format - integer} </p>
6899
<h3> Java Code </h3>
69100
```java
70101
CustomButton(Context context, LayoutParams layoutParams, int primaryColor, int secondaryColor, Drawable icon)
@@ -97,6 +128,7 @@ setTextPadding(int[] padding) - int[4]{CustomButton.LEFT, CustomButton.TOP, Cust
97128
setTextParams(int weight, int[] padding)
98129
setImage(int position, Drawable drawableNormal, Drawable drawablePressed, Drawable drawableDisabled, ImageView.ScaleType scaleType, int weight, int[] padding)
99130
setImage(int position, Drawable drawable, ImageView.ScaleType scaleType, int weight, int[] padding)
131+
setImageColor(int color)
100132
setImageColors(int nomal, int pressed, int disabled)
101133
setImageNormalColor(int color)
102134
setImagePressedColor(int color)
@@ -107,6 +139,9 @@ and evry XML tag have getter
107139
<h3> Static field </h3>
108140
LEFT, TOP, RIGHT, BOTTOM - for image position
109141

142+
<h3> Tips </h3>
143+
If you add image to the button, set frame and want to center text without respect frame you should set text padding same as frame size.
144+
110145
<h2> Dependencies </h2>
111146
In demo application <a href="https://github.com/yukuku/ambilwarna"> Ambil Warna Library</a> was used.
112147

app/src/main/res/layout/fragment_main.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,14 @@
8383
android:layout_weight="1"
8484
android:paddingRight="2dp"
8585
android:text="Create own button"
86-
app:cb_background="@android:color/transparent"
86+
app:cb_background="#f1c8c2"
8787
app:cb_frame_color="#DBBA23"
8888
app:cb_frame_color_disabled="#CFB957"
8989
app:cb_frame_color_pressed="#A88D13"
9090
app:cb_frame_size="5dp"
9191
app:cb_primary_color="#DB433B"
92-
app:cb_secondary_color="#E01E14" />
92+
app:cb_secondary_color="#E01E14"
93+
app:cb_shape_radius="5dp" />
9394

9495

9596
<pl.sigmapoint.customview.CustomButton

resources/screen.png

52.6 KB
Loading

0 commit comments

Comments
 (0)