Skip to content

Commit a4b753a

Browse files
author
xiaoqi
committed
支持selector
1 parent 5c07b4d commit a4b753a

File tree

9 files changed

+41
-27
lines changed

9 files changed

+41
-27
lines changed

.idea/caches/build_file_checksums.ser

0 Bytes
Binary file not shown.

app/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ android {
1616
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
1717
}
1818
}
19+
20+
lintOptions{
21+
abortOnError false
22+
}
1923
// buildToolsVersion '28.0.2'
2024
}
2125

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

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -59,34 +59,20 @@
5959
app:shape="rectangle" />
6060

6161
<TextView
62-
android:layout_width="130dp"
63-
android:layout_height="36dp"
64-
android:layout_marginTop="5dp"
65-
android:gravity="center"
66-
android:text="TextView"
67-
android:textColor="#8c6822"
68-
android:textSize="20sp"
6962
app:corners_radius="4dp"
7063
app:gradient_useLevel="true"
7164
app:solid_color="#E3B666"
7265
app:stroke_color="#8c6822"
7366
app:stroke_dashGap="5dp"
7467
app:stroke_dashWidth="10dp"
75-
app:stroke_width="2dp" />
76-
77-
<View
78-
android:layout_width="50dp"
79-
android:layout_height="50dp"
68+
app:stroke_width="2dp"
69+
android:layout_width="130dp"
70+
android:layout_height="36dp"
8071
android:layout_marginTop="5dp"
8172
android:gravity="center"
73+
android:text="TextView"
8274
android:textColor="#8c6822"
83-
android:textSize="20sp"
84-
app:shape="oval"
85-
app:solid_color="#E3B666"
86-
app:stroke_color="#8c6822"
87-
app:stroke_dashGap="5dp"
88-
app:stroke_dashWidth="10dp"
89-
app:stroke_width="2dp" />
75+
android:textSize="20sp"/>
9076

9177
<Button
9278
android:layout_width="300dp"
@@ -102,6 +88,20 @@
10288
app:unpressed_color="#7CFC00"
10389
app:pressed_color="#7CCD7C"/>
10490

91+
<View
92+
android:layout_width="50dp"
93+
android:layout_height="50dp"
94+
android:layout_marginTop="5dp"
95+
android:gravity="center"
96+
android:textColor="#8c6822"
97+
android:textSize="20sp"
98+
app:shape="rectangle"
99+
app:solid_color="#E3B666"
100+
app:stroke_color="#8c6822"
101+
app:stroke_width="2dp"
102+
app:stroke_dashGap="5dp"
103+
app:stroke_dashWidth="10dp"/>
104+
105105
<Button
106106
android:layout_width="300dp"
107107
android:layout_height="50dp"
@@ -111,9 +111,12 @@
111111
android:text="有波纹触摸反馈的按钮"
112112
android:textColor="@android:color/white"
113113
android:textSize="20sp"
114+
app:stroke_color="#8c6822"
115+
app:stroke_width="2dp"
114116
app:corners_radius="20dp"
115117
app:ripple_enable="true"
116118
app:ripple_color="#71C671"
117-
app:solid_color="#7CFC00"/>
119+
app:solid_color="#7CFC00"
120+
/>
118121

119122
</LinearLayout>

build.gradle

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ allprojects {
1818
google()
1919
jcenter()
2020
}
21+
tasks.withType(Javadoc) {
22+
options.addStringOption('Xdoclint:none', '-quiet')
23+
options.addStringOption('encoding', 'UTF-8')
24+
}
2125
}
2226

2327
task clean(type: Delete) {
@@ -29,7 +33,7 @@ ext {
2933
userOrg = 'noober'
3034
groupId = 'com.noober.backgorund'
3135
uploadName = 'Background'
32-
publishVersion = '1.0.0'
36+
publishVersion = '1.0.1'
3337
desc = "A framework for directly generating shape through Tags, no need to write shape.xml again(通过标签直接生成shape,无需再写shape.xml)"
3438
website = 'https://github.com/JavaNoober/BackgroudLibrary'
3539
// gradlew clean build bintrayUpload -PbintrayUser=xiaoqiandroid -PbintrayKey=xxxxxxxxxxxxxxxx -PdryRun=false

images/gif.gif

175 KB
Loading

images/gif1.gif

173 KB
Loading

images/gif2.gif

1.67 MB
Loading

library/src/main/java/com/noober/background/BackgroundFactory.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232

3333
public class BackgroundFactory implements LayoutInflater.Factory {
3434

35-
private static final int[][] EMPTY = new int[][] { new int[0] };
36-
3735
private LayoutInflater.Factory mViewCreateFactory;
3836

3937
public void setInterceptFactory(LayoutInflater.Factory factory) {

library/src/main/java/com/noober/background/BackgroundLibrary.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,16 @@
1010

1111
public class BackgroundLibrary {
1212

13-
public static void inject(Activity activity) {
14-
LayoutInflater inflater = activity.getLayoutInflater();
13+
public static void inject(Context context) {
14+
LayoutInflater inflater;
15+
if(context instanceof Activity){
16+
inflater = ((Activity)context).getLayoutInflater();
17+
}else {
18+
inflater = LayoutInflater.from(context);
19+
}
1520
BackgroundFactory factory = new BackgroundFactory();
16-
if (activity instanceof AppCompatActivity) {
17-
final AppCompatDelegate delegate = ((AppCompatActivity) activity).getDelegate();
21+
if (context instanceof AppCompatActivity) {
22+
final AppCompatDelegate delegate = ((AppCompatActivity) context).getDelegate();
1823
factory.setInterceptFactory(new LayoutInflater.Factory() {
1924
@Override
2025
public View onCreateView(String name, Context context, AttributeSet attrs) {

0 commit comments

Comments
 (0)