├── README.md
└── SpannableStringBuilderTest
├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── dictionaries
│ └── gavin.xml
├── gradle.xml
├── misc.xml
├── modules.xml
└── runConfigurations.xml
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── example
│ │ └── gavin
│ │ └── spannablestringbuildertest
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── gavin
│ │ │ └── spannablestringbuildertest
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── example
│ └── gavin
│ └── spannablestringbuildertest
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/README.md:
--------------------------------------------------------------------------------
1 | # 强大的SpannableStringBuilder
2 |
3 | ##前言
4 | 工作找完了,已经干了两个星期。虽然经常加班,不过相比之前的工作,现在过得更加充实、更有意义。
5 | 现在有点空闲时间,继续我的分享之旅~~
6 | ##效果
7 | 什么都不说,先看个炫酷的效果。
8 |
9 | 
10 |
11 |
12 | *‘什么,这也算炫酷?’*也许你会这么说
13 | 如果我告诉你,**这个页面中只用了一个`TextView`**,对!只有一个,没别的。
14 | 这时候你还觉得不炫酷?
15 |
16 | ##实现
17 | 是时候把`SpannableStringBuilder`介绍给大家了
18 | 先看看Google官方的介绍
19 | > This is the class for text whose content and markup can both be changed.
20 | (这是一个内容和标记都可以更改的文本类)
21 |
22 | 不同于我们平时赋值时使用的`String`、`StringBuffer`等,只能给`TextView`设置文本内容,而文本的样式只能用`TextView`来控制,而且该样式的可定制性还不大好。
23 | #### 介绍
24 | `SpannableStringBuilder`有个亲兄弟——`SpannableString`。是不是觉得有点熟悉?似乎看到了`StringBuilder`、`String`的影子...
25 | 是的,`SpannableStringBuilder`和`SpannableString`的区别类似与`StringBuilder`、`String`,就是`SpannableStringBuilder`可以拼接,而`SpannableString`不可拼接。
26 | 
27 | 图片来自http://blog.csdn.net/fengkuanghun/article/details/7904284
28 | 由图中可以看出,他们都继承了`CharSequence`,因此,他们可以直接在`TextView`的`setText`中使用
29 |
30 | #### 主要的方法
31 | `SpannableStringBuilder`和`SpannableString`主要通过使用`setSpan(Object what, int start, int end, int flags)`改变文本样式。
32 | 对应的参数:
33 | - start: 指定Span的开始位置
34 | - end: 指定Span的结束位置,并不包括这个位置。
35 | - flags:取值有如下四个
36 | - `Spannable.SPAN_EXCLUSIVE_INCLUSIVE`:在 Span前面输入的字符不应用 Span的效果,在后面输入的字符应用Span效果。
37 | - `Spannable.SPAN_INCLUSIVE_EXCLUSIVE`:在 Span前面输入的字符应用 Span 的效果,在后面输入的字符不应用Span效果。
38 | - `Spannable.SPAN_INCUJSIVE_INCLUSIVE`:在 Span前后输入的字符都应用 Span 的效果。
39 | - `Spannable.SPAN_EXCLUSIVE_EXCLUSIVE`:前后都不包括。
40 | - what: 对应的各种Span,不同的Span对应不同的样式。已知的可用类有:
41 | - `BackgroundColorSpan` : 文本背景色
42 | - `ForegroundColorSpan` : 文本颜色
43 | - `MaskFilterSpan` : 修饰效果,如模糊(BlurMaskFilter)浮雕
44 | - `RasterizerSpan` : 光栅效果
45 | - `StrikethroughSpan` : 删除线
46 | - `SuggestionSpan` : 相当于占位符
47 | - `UnderlineSpan` : 下划线
48 | - `AbsoluteSizeSpan` : 文本字体(绝对大小)
49 | - `DynamicDrawableSpan` : 设置图片,基于文本基线或底部对齐。
50 | - `ImageSpan` : 图片
51 | - `RelativeSizeSpan` : 相对大小(文本字体)
52 | - `ScaleXSpan` : 基于x轴缩放
53 | - `StyleSpan` : 字体样式:粗体、斜体等
54 | - `SubscriptSpan` : 下标(数学公式会用到)
55 | - `SuperscriptSpan` : 上标(数学公式会用到)
56 | - `TextAppearanceSpan` : 文本外貌(包括字体、大小、样式和颜色)
57 | - `TypefaceSpan` : 文本字体
58 | - `URLSpan` : 文本超链接
59 | - `ClickableSpan` : 点击事件
60 |
61 | ####用法
62 | 先在xml中创建一个`TextView`:
63 | ```java
64 |
69 | ```
70 | `SpannableStringBuilder`和`SpannableString`的用法差不多,这边先举一个`SpannableString`的例子
71 | - **SpannableString**
72 | - 修改字体颜色
73 | ```java
74 | /**
75 | * 使用SpannableString设置样式——字体颜色
76 | */
77 | private void mode1() {
78 | SpannableString spannableString = new SpannableString("暗影IV已经开始暴走了");
79 | ForegroundColorSpan colorSpan = new ForegroundColorSpan(Color.parseColor("#009ad6"));
80 | spannableString.setSpan(colorSpan, 0, 8, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
81 | ((TextView)findViewById(R.id.mode1)).setText(spannableString);
82 | }
83 | ```
84 | 创建`SpannableString`的时候,传入需要显示的字符串。使用`ForegroundColorSpan`为文字设置颜色。
85 | 效果:
86 | 
87 |
88 | 后面都以`SpannableStringBuilder`为例子
89 | - **SpannableStringBuilder**
90 | - 修改字体颜色
91 | ```java
92 |
93 | /**
94 | * 使用SpannableStringBuilder设置样式——字体颜色
95 | */
96 | private void mode2() {
97 | SpannableStringBuilder spannableString = new SpannableStringBuilder();
98 | spannableString.append("暗影IV");
99 | spannableString.append("已经开始暴走了");
100 | ForegroundColorSpan colorSpan = new ForegroundColorSpan(Color.parseColor("#009ad6"));
101 | spannableString.setSpan(colorSpan, 0, 8, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
102 | ((TextView)findViewById(R.id.mode2)).setText(spannableString);
103 | }
104 | ```
105 | 这里就可以看出`SpannableStringBuilder`的可拼接性,这里同样采用了`ForegroundColorSpan`为文本设置颜色。
106 | 效果:
107 | 
108 | - 设置背景颜色
109 | ```java
110 | /**
111 | * 使用SpannableStringBuilder设置样式——背景颜色
112 | */
113 | private void mode3() {
114 | SpannableStringBuilder spannableString = new SpannableStringBuilder();
115 | spannableString.append("暗影IV已经开始暴走了");
116 | BackgroundColorSpan bgColorSpan = new BackgroundColorSpan(Color.parseColor("#009ad6"));
117 | spannableString.setSpan(bgColorSpan, 0, 8, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
118 | ((TextView)findViewById(R.id.mode3)).setText(spannableString);
119 | }
120 | ```
121 | 使用`BackgroundColorSpan`设置背景颜色。
122 | 效果:
123 | 
124 | - 设置字体大小
125 | ```java
126 | /**
127 | * 使用SpannableStringBuilder设置样式——字体大小
128 | */
129 | private void mode4() {
130 | SpannableStringBuilder spannableString = new SpannableStringBuilder();
131 | spannableString.append("暗影IV已经开始暴走了");
132 | AbsoluteSizeSpan absoluteSizeSpan = new AbsoluteSizeSpan(20);
133 | spannableString.setSpan(absoluteSizeSpan, 0, 8, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
134 | ((TextView)findViewById(R.id.mode4)).setText(spannableString);
135 | }
136 | ```
137 | 使用`AbsoluteSizeSpan`设置字体大小。
138 | 效果:
139 | 
140 | - 设置粗体\斜体
141 | ```java
142 | /**
143 | * 使用SpannableStringBuilder设置样式——粗体\斜体
144 | */
145 | private void mode5() {
146 | SpannableStringBuilder spannableString = new SpannableStringBuilder();
147 | spannableString.append("暗影IV已经开始暴走了");
148 | //setSpan可多次使用
149 | StyleSpan styleSpan = new StyleSpan(Typeface.BOLD);//粗体
150 | spannableString.setSpan(styleSpan, 0, 3, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
151 | StyleSpan styleSpan2 = new StyleSpan(Typeface.ITALIC);//斜体
152 | spannableString.setSpan(styleSpan2, 3, 6, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
153 | StyleSpan styleSpan3 = new StyleSpan(Typeface.BOLD_ITALIC);//粗斜体
154 | spannableString.setSpan(styleSpan3, 6, 9, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
155 | ((TextView)findViewById(R.id.mode5)).setText(spannableString);
156 | }
157 | ```
158 | 使用`StyleSpan`设置粗体\斜体,从例子中可以看出,多次使用`setSpan`并不影响。
159 | 效果:
160 | 
161 | - 删除线
162 | ```java
163 | /**
164 | * 使用SpannableStringBuilder设置样式——删除线
165 | */
166 | private void mode6() {
167 | SpannableStringBuilder spannableString = new SpannableStringBuilder();
168 | spannableString.append("暗影IV已经开始暴走了");
169 | StrikethroughSpan strikethroughSpan = new StrikethroughSpan();
170 | spannableString.setSpan(strikethroughSpan, 0, 8, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
171 | ((TextView)findViewById(R.id.mode6)).setText(spannableString);
172 | }
173 | ```
174 | StrikethroughSpa使用`StrikethroughSpan`设置删除线。
175 | 效果:
176 | 
177 | - 下划线
178 | ```java
179 | /**
180 | * 使用SpannableStringBuilder设置样式——下划线
181 | */
182 | private void mode7() {
183 | SpannableStringBuilder spannableString = new SpannableStringBuilder();
184 | spannableString.append("暗影IV已经开始暴走了");
185 | UnderlineSpan underlineSpan = new UnderlineSpan();
186 | spannableString.setSpan(underlineSpan, 0, 8, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
187 | ((TextView)findViewById(R.id.mode7)).setText(spannableString);
188 | }
189 | ```
190 | 使用`UnderlineSpan`设置下划线。
191 | 效果:
192 | 
193 | - 图片
194 | 不仅支持文字样式,还可以插入图片。厉害了我的`SpannableStringBuilder`~~
195 | ```java
196 | /**
197 | * 使用SpannableStringBuilder设置样式——图片
198 | */
199 | private void mode8() {
200 | SpannableStringBuilder spannableString = new SpannableStringBuilder();
201 | spannableString.append("暗影IV已经开始暴走了");
202 | ImageSpan imageSpan = new ImageSpan(this, R.mipmap.ic_launcher);
203 | //也可以这样
204 | //Drawable drawable = getResources().getDrawable(R.mipmap.ic_launcher);
205 | //drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
206 | //ImageSpan imageSpan1 = new ImageSpan(drawable);
207 | //将index为6、7的字符用图片替代
208 | spannableString.setSpan(imageSpan, 6, 8, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
209 | ((TextView)findViewById(R.id.mode8)).setText(spannableString);
210 | }
211 | ```
212 | 使用ImageSpan设置图片,将index为6、7的字符替换成了图片,也就是说,该图片占有index6和7的位置。
213 | 效果:
214 | 
215 | - 点击事件
216 | 插入图片就已经很变态了,居然还支持点击事件。
217 | ```java
218 | /**
219 | * 使用SpannableStringBuilder设置点击事件
220 | */
221 | private void mode9() {
222 | SpannableStringBuilder spannableString = new SpannableStringBuilder();
223 | spannableString.append("暗影IV已经开始暴走了");
224 | ClickableSpan clickableSpan = new ClickableSpan() {
225 | @Override
226 | public void onClick(View view) {
227 | Toast.makeText(MainActivity.this, "请不要点我", Toast.LENGTH_SHORT).show();
228 | }
229 | };
230 | spannableString.setSpan(clickableSpan, 5, 8, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
231 | TextView textView = (TextView)findViewById(R.id.mode9);
232 | textView.setText(spannableString);
233 | textView.setMovementMethod(LinkMovementMethod.getInstance());
234 | }
235 | ```
236 | 使用`ClickableSpan`设置点击事件,最后还需要加上`textView.setMovementMethod(LinkMovementMethod.getInstance());`。代码中指定index为5、6、7的字符都成了可点击的文本,其他区域还是不可点击的。
237 | 效果:
238 | 
239 | - 组合使用
240 | 当然,上面的这些用法都能组合使用。来个🌰
241 | ```java
242 | /**
243 | * 使用SpannableStringBuilder事件组合使用
244 | */
245 | private void mode10() {
246 | SpannableStringBuilder spannableString = new SpannableStringBuilder();
247 | spannableString.append("暗影IV已经开始暴走了");
248 | //图片
249 | ImageSpan imageSpan = new ImageSpan(this, R.mipmap.ic_launcher);
250 | spannableString.setSpan(imageSpan, 2, 4, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
251 | //点击事件
252 | ClickableSpan clickableSpan = new ClickableSpan() {
253 | @Override
254 | public void onClick(View view) {
255 | Toast.makeText(MainActivity.this, "请不要点我", Toast.LENGTH_SHORT).show();
256 | }
257 | };
258 | spannableString.setSpan(clickableSpan, 2, 4, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
259 | //文字颜色
260 | ForegroundColorSpan colorSpan = new ForegroundColorSpan(Color.parseColor("#FFFFFF"));
261 | spannableString.setSpan(colorSpan,5, 8, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
262 | //文字背景颜色
263 | BackgroundColorSpan bgColorSpan = new BackgroundColorSpan(Color.parseColor("#009ad6"));
264 | spannableString.setSpan(bgColorSpan, 5, 8, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
265 | TextView textView = (TextView)findViewById(R.id.mode10);
266 | textView.setText(spannableString);
267 | textView.setMovementMethod(LinkMovementMethod.getInstance());
268 | }
269 | ```
270 | 例子中将`ImageSpan`、`ClickableSpan `、`ForegroundColorSpan `、`BackgroundColorSpan `进行了组合使用,大家根据自己的需求,来随意搭配。
271 | 效果:(就是刚开始展示的那张gif)
272 | 
273 |
274 | ## 总结
275 | 看完后,感觉`SpannableStringBuilder`和`SpannableString`相比`String`要强大太多了。额~~没别的了,发表睡觉
276 |
277 | ## 参考资料
278 | [SpannableString与SpannableStringBuilder](http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2015/1009/3553.html)
279 | [API 文档(自备梯子)](https://developer.android.com/reference/android/text/SpannableStringBuilder.html)
280 | [SpannableString与SpannableStringBuilder](http://blog.csdn.net/harvic880925/article/details/38984705)
281 |
282 | > 以上有错误之处,感谢指出
283 |
284 |
285 |
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/.idea/dictionaries/gavin.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 | Android > Lint > Correctness
39 |
40 |
41 | Android > Lint > Performance
42 |
43 |
44 |
45 |
46 | Android
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 25
5 | buildToolsVersion "25.0.0"
6 | defaultConfig {
7 | applicationId "com.example.gavin.spannablestringbuildertest"
8 | minSdkVersion 15
9 | targetSdkVersion 25
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | compile 'com.android.support:appcompat-v7:25.0.0'
28 | testCompile 'junit:junit:4.12'
29 | }
30 |
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/gavin/Library/Android/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/app/src/androidTest/java/com/example/gavin/spannablestringbuildertest/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.example.gavin.spannablestringbuildertest;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.example.gavin.spannablestringbuildertest", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/app/src/main/java/com/example/gavin/spannablestringbuildertest/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.gavin.spannablestringbuildertest;
2 |
3 | import android.graphics.Color;
4 | import android.graphics.Typeface;
5 | import android.os.Bundle;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.text.Spannable;
8 | import android.text.SpannableString;
9 | import android.text.SpannableStringBuilder;
10 | import android.text.method.LinkMovementMethod;
11 | import android.text.style.AbsoluteSizeSpan;
12 | import android.text.style.BackgroundColorSpan;
13 | import android.text.style.ClickableSpan;
14 | import android.text.style.ForegroundColorSpan;
15 | import android.text.style.ImageSpan;
16 | import android.text.style.StrikethroughSpan;
17 | import android.text.style.StyleSpan;
18 | import android.text.style.UnderlineSpan;
19 | import android.view.View;
20 | import android.widget.TextView;
21 | import android.widget.Toast;
22 |
23 | public class MainActivity extends AppCompatActivity {
24 |
25 |
26 | @Override
27 | protected void onCreate(Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | setContentView(R.layout.activity_main);
30 | mode1();
31 | mode2();
32 | mode3();
33 | mode4();
34 | mode5();
35 | mode6();
36 | mode7();
37 | mode8();
38 | mode9();
39 | //mode10();
40 | }
41 |
42 | /**
43 | * 使用SpannableString设置样式——字体颜色
44 | */
45 | private void mode1() {
46 | SpannableString spannableString = new SpannableString("暗影IV已经开始暴走了");
47 | ForegroundColorSpan colorSpan = new ForegroundColorSpan(Color.parseColor("#009ad6"));
48 | spannableString.setSpan(colorSpan, 0, 8, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
49 | ((TextView)findViewById(R.id.mode1)).setText(spannableString);
50 | }
51 |
52 | /**
53 | * 使用SpannableStringBuilder设置样式——字体颜色
54 | */
55 | private void mode2() {
56 | SpannableStringBuilder spannableString = new SpannableStringBuilder();
57 | spannableString.append("暗影IV");
58 | spannableString.append("已经开始暴走了");
59 | ForegroundColorSpan colorSpan = new ForegroundColorSpan(Color.parseColor("#009ad6"));
60 | spannableString.setSpan(colorSpan, 0, 8, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
61 | ((TextView)findViewById(R.id.mode2)).setText(spannableString);
62 | }
63 |
64 | /**
65 | * 使用SpannableStringBuilder设置样式——背景颜色
66 | */
67 | private void mode3() {
68 | SpannableStringBuilder spannableString = new SpannableStringBuilder();
69 | spannableString.append("暗影IV已经开始暴走了");
70 | BackgroundColorSpan bgColorSpan = new BackgroundColorSpan(Color.parseColor("#009ad6"));
71 | spannableString.setSpan(bgColorSpan, 0, 8, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
72 | ((TextView)findViewById(R.id.mode3)).setText(spannableString);
73 | }
74 |
75 | /**
76 | * 使用SpannableStringBuilder设置样式——字体大小
77 | */
78 | private void mode4() {
79 | SpannableStringBuilder spannableString = new SpannableStringBuilder();
80 | spannableString.append("暗影IV已经开始暴走了");
81 | AbsoluteSizeSpan absoluteSizeSpan = new AbsoluteSizeSpan(20);
82 | spannableString.setSpan(absoluteSizeSpan, 0, 8, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
83 | ((TextView)findViewById(R.id.mode4)).setText(spannableString);
84 | }
85 |
86 | /**
87 | * 使用SpannableStringBuilder设置样式——粗体\斜体
88 | */
89 | private void mode5() {
90 | SpannableStringBuilder spannableString = new SpannableStringBuilder();
91 | spannableString.append("暗影IV已经开始暴走了");
92 | //setSpan可多次使用
93 | StyleSpan styleSpan = new StyleSpan(Typeface.BOLD);//粗体
94 | spannableString.setSpan(styleSpan, 0, 3, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
95 | StyleSpan styleSpan2 = new StyleSpan(Typeface.ITALIC);//斜体
96 | spannableString.setSpan(styleSpan2, 3, 6, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
97 | StyleSpan styleSpan3 = new StyleSpan(Typeface.BOLD_ITALIC);//粗斜体
98 | spannableString.setSpan(styleSpan3, 6, 9, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
99 | ((TextView)findViewById(R.id.mode5)).setText(spannableString);
100 | }
101 |
102 | /**
103 | * 使用SpannableStringBuilder设置样式——删除线
104 | */
105 | private void mode6() {
106 | SpannableStringBuilder spannableString = new SpannableStringBuilder();
107 | spannableString.append("暗影IV已经开始暴走了");
108 | StrikethroughSpan strikethroughSpan = new StrikethroughSpan();
109 | spannableString.setSpan(strikethroughSpan, 0, 8, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
110 | ((TextView)findViewById(R.id.mode6)).setText(spannableString);
111 | }
112 |
113 | /**
114 | * 使用SpannableStringBuilder设置样式——下划线
115 | */
116 | private void mode7() {
117 | SpannableStringBuilder spannableString = new SpannableStringBuilder();
118 | spannableString.append("暗影IV已经开始暴走了");
119 | UnderlineSpan underlineSpan = new UnderlineSpan();
120 | spannableString.setSpan(underlineSpan, 0, 8, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
121 | ((TextView)findViewById(R.id.mode7)).setText(spannableString);
122 | }
123 |
124 | /**
125 | * 使用SpannableStringBuilder设置样式——图片
126 | */
127 | private void mode8() {
128 | SpannableStringBuilder spannableString = new SpannableStringBuilder();
129 | spannableString.append("暗影IV已经开始暴走了");
130 | ImageSpan imageSpan = new ImageSpan(this, R.mipmap.ic_launcher);
131 | //也可以这样
132 | //Drawable drawable = getResources().getDrawable(R.mipmap.ic_launcher);
133 | //drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
134 | //ImageSpan imageSpan1 = new ImageSpan(drawable);
135 | //将index为6、7的字符用图片替代
136 | spannableString.setSpan(imageSpan, 6, 8, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
137 | ((TextView)findViewById(R.id.mode8)).setText(spannableString);
138 | }
139 |
140 | /**
141 | * 使用SpannableStringBuilder设置点击事件
142 | */
143 | private void mode9() {
144 | SpannableStringBuilder spannableString = new SpannableStringBuilder();
145 | spannableString.append("暗影IV已经开始暴走了");
146 | ClickableSpan clickableSpan = new ClickableSpan() {
147 | @Override
148 | public void onClick(View view) {
149 | Toast.makeText(MainActivity.this, "请不要点我", Toast.LENGTH_SHORT).show();
150 | }
151 | };
152 | spannableString.setSpan(clickableSpan, 5, 8, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
153 | TextView textView = (TextView)findViewById(R.id.mode9);
154 | textView.setText(spannableString);
155 | textView.setMovementMethod(LinkMovementMethod.getInstance());
156 | }
157 |
158 | /**
159 | * 使用SpannableStringBuilder事件组合使用
160 | */
161 | private void mode10() {
162 | SpannableStringBuilder spannableString = new SpannableStringBuilder();
163 | spannableString.append("暗影IV已经开始暴走了");
164 | //图片
165 | ImageSpan imageSpan = new ImageSpan(this, R.mipmap.ic_launcher);
166 | spannableString.setSpan(imageSpan, 2, 4, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
167 | //点击事件
168 | ClickableSpan clickableSpan = new ClickableSpan() {
169 | @Override
170 | public void onClick(View view) {
171 | Toast.makeText(MainActivity.this, "请不要点我", Toast.LENGTH_SHORT).show();
172 | }
173 | };
174 | spannableString.setSpan(clickableSpan, 2, 4, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
175 | //文字颜色
176 | ForegroundColorSpan colorSpan = new ForegroundColorSpan(Color.parseColor("#FFFFFF"));
177 | spannableString.setSpan(colorSpan,5, 8, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
178 | //文字背景颜色
179 | BackgroundColorSpan bgColorSpan = new BackgroundColorSpan(Color.parseColor("#009ad6"));
180 | spannableString.setSpan(bgColorSpan, 5, 8, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
181 | TextView textView = (TextView)findViewById(R.id.mode10);
182 | textView.setText(spannableString);
183 | textView.setMovementMethod(LinkMovementMethod.getInstance());
184 | }
185 |
186 | }
187 |
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
21 |
27 |
33 |
39 |
45 |
51 |
57 |
63 |
69 |
75 |
76 |
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gavin-ZYX/SpannableStringBiulderTest/7e44596b56bea6fe36d71b0f22c6793a8b6031d2/SpannableStringBuilderTest/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gavin-ZYX/SpannableStringBiulderTest/7e44596b56bea6fe36d71b0f22c6793a8b6031d2/SpannableStringBuilderTest/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gavin-ZYX/SpannableStringBiulderTest/7e44596b56bea6fe36d71b0f22c6793a8b6031d2/SpannableStringBuilderTest/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gavin-ZYX/SpannableStringBiulderTest/7e44596b56bea6fe36d71b0f22c6793a8b6031d2/SpannableStringBuilderTest/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gavin-ZYX/SpannableStringBiulderTest/7e44596b56bea6fe36d71b0f22c6793a8b6031d2/SpannableStringBuilderTest/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | SpannableStringBuilderTest
3 |
4 |
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/app/src/test/java/com/example/gavin/spannablestringbuildertest/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.example.gavin.spannablestringbuildertest;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.2.2'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Gavin-ZYX/SpannableStringBiulderTest/7e44596b56bea6fe36d71b0f22c6793a8b6031d2/SpannableStringBuilderTest/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/SpannableStringBuilderTest/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------