Skip to content

Commit 41b0016

Browse files
committed
Using DrawableBuilder from DrawableToolbox
1 parent 38b3aa0 commit 41b0016

File tree

8 files changed

+21
-25
lines changed

8 files changed

+21
-25
lines changed

app/build.gradle

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ android {
1010
versionName "1.0"
1111
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1212
}
13+
compileOptions {
14+
sourceCompatibility JavaVersion.VERSION_1_8
15+
targetCompatibility JavaVersion.VERSION_1_8
16+
}
1317
buildTypes {
1418
release {
1519
minifyEnabled false
@@ -21,11 +25,12 @@ android {
2125
dependencies {
2226
implementation fileTree(include: ['*.jar'], dir: 'libs')
2327
implementation 'com.android.support:appcompat-v7:27.1.1'
24-
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
28+
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
2529
implementation 'com.jakewharton:butterknife:8.7.0'
2630
implementation 'com.google.android:flexbox:1.0.0'
2731
annotationProcessor 'com.jakewharton:butterknife-compiler:8.7.0'
2832
implementation 'com.github.duanhong169:logger:1.0.0'
33+
implementation 'com.github.duanhong169:drawabletoolbox:1.0.1'
2934
implementation 'com.github.duanhong169:text-button:1.0.4'
3035
// implementation project(':text-button')
3136
testImplementation 'junit:junit:4.12'

app/src/main/java/top/defaults/textbuttonapp/MainActivity.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package top.defaults.textbuttonapp;
22

3+
import android.support.v4.content.ContextCompat;
34
import android.support.v7.app.AppCompatActivity;
45
import android.os.Bundle;
5-
import android.view.View;
66
import android.widget.TextView;
77

88
import java.util.ArrayList;
@@ -12,6 +12,7 @@
1212
import butterknife.ButterKnife;
1313
import butterknife.OnCheckedChanged;
1414
import butterknife.OnClick;
15+
import top.defaults.drawabletoolbox.DrawableBuilder;
1516
import top.defaults.logger.Logger;
1617
import top.defaults.view.RippleEffect;
1718
import top.defaults.view.TextButton;
@@ -64,6 +65,16 @@ protected void onCreate(Bundle savedInstanceState) {
6465
setContentView(R.layout.activity_main);
6566
ButterKnife.bind(this);
6667

68+
button1.setBackgroundDrawable(new DrawableBuilder()
69+
.rectangle()
70+
.rounded()
71+
.hairlineBordered()
72+
.strokeColor(ContextCompat.getColor(this, android.R.color.holo_purple))
73+
.strokeColorPressed(ContextCompat.getColor(this, android.R.color.holo_orange_light))
74+
.strokeColorSelected(ContextCompat.getColor(this, android.R.color.holo_orange_dark))
75+
.solidColorSelected(ContextCompat.getColor(this, android.R.color.holo_orange_light))
76+
.build());
77+
6778
buttons.add(button0);
6879
buttons.add(button1);
6980
buttons.add(button2);

app/src/main/res/drawable/bg_round_border_button.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.

app/src/main/res/drawable/bg_round_border_button_default.xml

Lines changed: 0 additions & 5 deletions
This file was deleted.

app/src/main/res/drawable/bg_round_border_button_pressed.xml

Lines changed: 0 additions & 5 deletions
This file was deleted.

app/src/main/res/drawable/bg_round_border_button_selected.xml

Lines changed: 0 additions & 6 deletions
This file was deleted.

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
android:text="default"
5858
android:padding="4dp"
5959
android:textSize="16sp"
60-
android:background="@drawable/bg_round_border_button"
6160
app:defaultTextColor="@android:color/holo_purple"
6261
app:pressedTextColor="@android:color/holo_orange_dark"
6362
app:underline="true"/>

build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ allprojects {
2020
repositories {
2121
google()
2222
jcenter()
23+
maven {
24+
url "https://dl.bintray.com/duanhong169/Hong"
25+
}
2326
}
2427
}
2528

0 commit comments

Comments
 (0)