Skip to content

Commit 45dffca

Browse files
committed
1.Support for setting 'Network Image' in XML for StateDrawable and StateDrawable2
1 parent 94ca8de commit 45dffca

File tree

8 files changed

+263
-14
lines changed

8 files changed

+263
-14
lines changed

README.md

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Hello, Developer!Welcome to use SuperTextView
66

77

8-
[![](https://jitpack.io/v/chenbingx/supertextview.svg)](https://jitpack.io/#chenbingx/supertextview) [![](https://img.shields.io/badge/SuperTextView-v3.2.5-orange.svg)](https://github.com/chenBingX/SuperTextView) [![](https://img.shields.io/badge/SuperTextView-v3.2.5.64-orange.svg)](https://github.com/chenBingX/SuperTextView) [![](https://img.shields.io/badge/build-passing-brightgreen.svg)](https://github.com/chenBingX/SuperTextView) [![](https://img.shields.io/badge/API-19+-yellowgreen.svg)](https://android-arsenal.com/api?level=14#l14) [![](https://img.shields.io/badge/License-Apache--2.0-blueviolet.svg)](https://github.com/chenBingX/SuperTextView#license) [![](https://img.shields.io/badge/Author-CoorChice-blue.svg)](https://weibo.com/5406092281/profile?topnav=1&wvr=6) [![](https://img.shields.io/badge/QQ--Group-775951525-ff5722.svg)](https://jq.qq.com/?_wv=1027&k=5DIRlPm)
8+
[![](https://jitpack.io/v/chenbingx/supertextview.svg)](https://jitpack.io/#chenbingx/supertextview) [![](https://img.shields.io/badge/SuperTextView-v3.2.6-orange.svg)](https://github.com/chenBingX/SuperTextView) [![](https://img.shields.io/badge/SuperTextView-v3.2.6.64-orange.svg)](https://github.com/chenBingX/SuperTextView) [![](https://img.shields.io/badge/build-passing-brightgreen.svg)](https://github.com/chenBingX/SuperTextView) [![](https://img.shields.io/badge/API-19+-yellowgreen.svg)](https://android-arsenal.com/api?level=14#l14) [![](https://img.shields.io/badge/License-Apache--2.0-blueviolet.svg)](https://github.com/chenBingX/SuperTextView#license) [![](https://img.shields.io/badge/Author-CoorChice-blue.svg)](https://weibo.com/5406092281/profile?topnav=1&wvr=6) [![](https://img.shields.io/badge/QQ--Group-775951525-ff5722.svg)](https://jq.qq.com/?_wv=1027&k=5DIRlPm)
99

1010

1111
# **English** | [**中文**](https://github.com/chenBingX/SuperTextView/blob/master/README_CN.md)
@@ -35,6 +35,7 @@ You just enjoy the amazing visual effects you have written, and the rest will be
3535
- support gradient background
3636
- touch discoloration
3737
- display pictures, including the net pictures
38+
- Supports setting network image directly in XML
3839
- set rounded corners for pictures
3940
- add borders to pictures
4041
- **Adjuster** module can insert operation
@@ -90,16 +91,70 @@ dependencies {
9091

9192
# Special Note💡
9293

93-
- **v3.2.5** support:`armeabi-v7a`
94+
- **v3.2.6** support:`armeabi-v7a`
9495

95-
- **v3.2.5.64** support:`armeabi-v7a``arm64-v8a`
96+
- **v3.2.6.64** support:`armeabi-v7a``arm64-v8a`
9697

97-
- **v3.2.5.99** support:`armeabi-v7a``arm64-v8a``x86`
98+
- **v3.2.6.99** support:`armeabi-v7a``arm64-v8a``x86`
9899

99100
- ⚠️Attention: **`proguard-rules.pro`** please add `-keep class com.coorchice.library.gifdecoder.JNI { *; }`
100101

101102
# Update Log
102103

104+
## v3.2.6
105+
106+
- Support for setting 'Network Image' in XML for StateDrawable and StateDrawable2
107+
108+
> In XML, use a 'Network Image' as a background image
109+
110+
![](https://gw.alicdn.com/imgextra/i1/O1CN01Pw9Z0U21Ie9BK88T9_!!6000000006962-0-tps-730-344.jpg)
111+
112+
```html
113+
<com.coorchice.library.SuperTextView
114+
android:id="@+id/stv_40"
115+
android:layout_width="150dp"
116+
android:layout_height="150dp"
117+
android:layout_gravity="center_horizontal"
118+
android:layout_marginTop="16dp"
119+
android:gravity="bottom|center"
120+
android:paddingBottom="1dp"
121+
android:text="网络背景图"
122+
android:textColor="#000"
123+
android:textSize="14sp"
124+
app:stv_corner="10dp"
125+
app:stv_isShowState="true"
126+
app:stv_drawableAsBackground="true"
127+
app:stv_solid="#f1f1f1"
128+
app:stv_state_drawable="https://gw.alicdn.com/imgextra/i3/O1CN01suhAFr1cXQX49D2xp_!!6000000003610-0-tps-468-466.jpg" />
129+
```
130+
131+
> In XML, set the 'Network Image' for StateDrawable2
132+
133+
![](https://gw.alicdn.com/imgextra/i4/O1CN01j3XdIb1LHXK50WtRd_!!6000000001274-0-tps-736-236.jpg)
134+
135+
```html
136+
<com.coorchice.library.SuperTextView
137+
android:id="@+id/stv_41"
138+
android:layout_width="350dp"
139+
android:layout_height="100dp"
140+
android:layout_gravity="center_horizontal"
141+
android:layout_marginTop="30dp"
142+
android:paddingLeft="116dp"
143+
android:paddingTop="30dp"
144+
android:text="StateDrawable2 网络图"
145+
android:textColor="@color/black"
146+
android:textSize="14sp"
147+
app:stv_corner="50dp"
148+
app:stv_isShowState2="true"
149+
app:stv_left_bottom_corner="true"
150+
app:stv_left_top_corner="true"
151+
app:stv_solid="#f1f1f1"
152+
app:stv_state_drawable2="https://gw.alicdn.com/imgextra/i3/O1CN01XPmcmt1vJfKcQ8o6O_!!6000000006152-0-tps-500-500.jpg"
153+
app:stv_state_drawable2_height="100dp"
154+
app:stv_state_drawable2_mode="left"
155+
app:stv_state_drawable2_width="100dp"/>
156+
```
157+
103158
## v3.2.5
104159

105160
- 【fix】 `stv_pressBgColor` invalid

README_CN.md

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# 你好, 开发者!欢迎使用 SuperTextView
22

33

4-
[![](https://jitpack.io/v/chenbingx/supertextview.svg)](https://jitpack.io/#chenbingx/supertextview) [![](https://img.shields.io/badge/SuperTextView-v3.2.5-orange.svg)](https://github.com/chenBingX/SuperTextView) [![](https://img.shields.io/badge/SuperTextView-v3.2.5.64-orange.svg)](https://github.com/chenBingX/SuperTextView) [![](https://img.shields.io/badge/build-passing-brightgreen.svg)](https://github.com/chenBingX/SuperTextView) [![](https://img.shields.io/badge/API-19+-yellowgreen.svg)](https://android-arsenal.com/api?level=14#l14) [![](https://img.shields.io/badge/License-Apache--2.0-blueviolet.svg)](https://github.com/chenBingX/SuperTextView#license) [![](https://img.shields.io/badge/Author-CoorChice-blue.svg)](https://weibo.com/5406092281/profile?topnav=1&wvr=6) [![](https://img.shields.io/badge/交流群-775951525-ff5722.svg)](https://jq.qq.com/?_wv=1027&k=5DIRlPm)
4+
[![](https://jitpack.io/v/chenbingx/supertextview.svg)](https://jitpack.io/#chenbingx/supertextview) [![](https://img.shields.io/badge/SuperTextView-v3.2.6-orange.svg)](https://github.com/chenBingX/SuperTextView) [![](https://img.shields.io/badge/SuperTextView-v3.2.6.64-orange.svg)](https://github.com/chenBingX/SuperTextView) [![](https://img.shields.io/badge/build-passing-brightgreen.svg)](https://github.com/chenBingX/SuperTextView) [![](https://img.shields.io/badge/API-19+-yellowgreen.svg)](https://android-arsenal.com/api?level=14#l14) [![](https://img.shields.io/badge/License-Apache--2.0-blueviolet.svg)](https://github.com/chenBingX/SuperTextView#license) [![](https://img.shields.io/badge/Author-CoorChice-blue.svg)](https://weibo.com/5406092281/profile?topnav=1&wvr=6) [![](https://img.shields.io/badge/交流群-775951525-ff5722.svg)](https://jq.qq.com/?_wv=1027&k=5DIRlPm)
55

66

77
# [**English**](https://github.com/chenBingX/SuperTextView) | **中文**
@@ -28,6 +28,7 @@
2828
- 支持渐变色背景
2929
- 触摸变色
3030
- 展示图片,包括网络图片
31+
- 支持 XML 中直接设置网络图片
3132
- 为图片设置圆角
3233
- 为图片增加边框
3334
- 可插入操作的 **Adjuster** 模块
@@ -83,17 +84,70 @@ dependencies {
8384

8485
# 特别提示💡
8586

86-
- **v3.2.5** 版本支持:`armeabi-v7a`
87+
- **v3.2.6** 版本支持:`armeabi-v7a`
8788

88-
- **v3.2.5.64** 版本支持:`armeabi-v7a``arm64-v8a`
89+
- **v3.2.6.64** 版本支持:`armeabi-v7a``arm64-v8a`
8990

90-
- **v3.2.5.99** 版本支持:`armeabi-v7a``arm64-v8a``x86`
91+
- **v3.2.6.99** 版本支持:`armeabi-v7a``arm64-v8a``x86`
9192

9293
- ⚠️ 特别注意:混淆请加上 `-keep class com.coorchice.library.gifdecoder.JNI { *; }`
9394

9495

9596
# 近期更新
9697

98+
## v3.2.6
99+
100+
- 支持在 XML 中,为 StateDrawable 和 StateDrawable2 设置网络图片
101+
102+
> 在 XML 中,把网络图片作为背景图
103+
104+
![](https://gw.alicdn.com/imgextra/i1/O1CN01Pw9Z0U21Ie9BK88T9_!!6000000006962-0-tps-730-344.jpg)
105+
106+
```html
107+
<com.coorchice.library.SuperTextView
108+
android:id="@+id/stv_40"
109+
android:layout_width="150dp"
110+
android:layout_height="150dp"
111+
android:layout_gravity="center_horizontal"
112+
android:layout_marginTop="16dp"
113+
android:gravity="bottom|center"
114+
android:paddingBottom="1dp"
115+
android:text="网络背景图"
116+
android:textColor="#000"
117+
android:textSize="14sp"
118+
app:stv_corner="10dp"
119+
app:stv_isShowState="true"
120+
app:stv_drawableAsBackground="true"
121+
app:stv_solid="#f1f1f1"
122+
app:stv_state_drawable="https://gw.alicdn.com/imgextra/i3/O1CN01suhAFr1cXQX49D2xp_!!6000000003610-0-tps-468-466.jpg" />
123+
```
124+
125+
> 在 XML 中,为 StateDrawable2 设置网络图片
126+
127+
![](https://gw.alicdn.com/imgextra/i4/O1CN01j3XdIb1LHXK50WtRd_!!6000000001274-0-tps-736-236.jpg)
128+
129+
```html
130+
<com.coorchice.library.SuperTextView
131+
android:id="@+id/stv_41"
132+
android:layout_width="350dp"
133+
android:layout_height="100dp"
134+
android:layout_gravity="center_horizontal"
135+
android:layout_marginTop="30dp"
136+
android:paddingLeft="116dp"
137+
android:paddingTop="30dp"
138+
android:text="StateDrawable2 网络图"
139+
android:textColor="@color/black"
140+
android:textSize="14sp"
141+
app:stv_corner="50dp"
142+
app:stv_isShowState2="true"
143+
app:stv_left_bottom_corner="true"
144+
app:stv_left_top_corner="true"
145+
app:stv_solid="#f1f1f1"
146+
app:stv_state_drawable2="https://gw.alicdn.com/imgextra/i3/O1CN01XPmcmt1vJfKcQ8o6O_!!6000000006152-0-tps-500-500.jpg"
147+
app:stv_state_drawable2_height="100dp"
148+
app:stv_state_drawable2_mode="left"
149+
app:stv_state_drawable2_width="100dp"/>
150+
```
97151
## v3.2.5
98152

99153
- 修复 `stv_pressBgColor` 失效

app/src/main/java/com/coorchice/supertextview/GifListActivity.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import com.coorchice.library.OnDrawableClickedListenerAdapter;
1111
import com.coorchice.library.SuperTextView;
12+
import com.coorchice.library.gifdecoder.GifCache;
1213
import com.coorchice.library.gifdecoder.GifDrawable;
1314
import com.coorchice.library.utils.STVUtils;
1415
import com.coorchice.library.utils.ThreadPool;
@@ -52,6 +53,7 @@ private void initView() {
5253

5354
if (stv_1.getDrawable() instanceof GifDrawable) {
5455
GifDrawable gifDrawable = (GifDrawable) stv_1.getDrawable();
56+
gifDrawable.play();
5557
// gifDrawable.setFrameDuration(25);
5658
}
5759

app/src/main/java/com/coorchice/supertextview/TestActivity.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
import android.graphics.drawable.ColorDrawable;
2121
import android.support.v7.app.ActionBarActivity;
2222
import android.os.Bundle;
23+
import android.support.v7.widget.RecyclerView;
24+
import android.view.Gravity;
25+
import android.view.LayoutInflater;
2326
import android.view.MotionEvent;
2427
import android.view.View;
2528
import android.view.ViewGroup;
@@ -43,6 +46,7 @@ public class TestActivity extends ActionBarActivity {
4346
private SuperTextView stv_0;
4447
private SuperTextView stv_1;
4548
private ImageView img_gif;
49+
private LinearLayout rootView;
4650

4751
@Override
4852
protected void onCreate(Bundle savedInstanceState) {
@@ -100,10 +104,28 @@ public void onDrawable1Clicked(SuperTextView stv) {
100104
//
101105
// }
102106
// });
107+
SuperTextView stv = (SuperTextView) LayoutInflater.from(this).inflate(R.layout.stv, rootView, false);
108+
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(300, 100);
109+
params.setMargins(100, 50, 0 , 100);
110+
stv.setLayoutParams(params);
111+
stv.setTextColor(Color.parseColor("#666666"));
112+
stv.setSolid(Color.parseColor("#FFFDF4"));
113+
stv.setTextSize(11);
114+
stv.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);
115+
stv.setShowState(true);
116+
stv.setUrlImage("https://gw.alicdn.com/tfs/TB1PWPqtCzqK1RjSZFLXXcn2XXa-160-96.png", false);
117+
// stv.setDrawableTint(SuperTextView.NO_COLOR);
118+
// stv.setDrawableRotate(SuperTextView.NO_ROTATE);
119+
stv.setStateDrawableMode(SuperTextView.DrawableMode.TOP);
120+
stv.setDrawableWidth(36);
121+
stv.setDrawableHeight(36);
122+
stv.setText("IconText");
123+
rootView.addView(stv);
103124
}
104125

105126

106127
private void findViews() {
128+
rootView = (LinearLayout) findViewById(R.id.ll_root);
107129
// stv_0 = (SuperTextView) findViewById(R.id.stv_0);
108130
stv_1 = (SuperTextView) findViewById(R.id.stv_1);
109131
img_gif = (ImageView) findViewById(R.id.img_gif);

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,53 @@
838838
app:stv_state_drawable_padding_left="5dp"
839839
app:stv_state_drawable_width="40dp" />
840840

841+
<TextView
842+
android:layout_width="wrap_content"
843+
android:layout_height="wrap_content"
844+
android:layout_gravity="center_horizontal"
845+
android:layout_marginTop="10dp"
846+
android:text="使用网络图片"
847+
android:textSize="20sp" />
848+
849+
<com.coorchice.library.SuperTextView
850+
android:id="@+id/stv_40"
851+
android:layout_width="150dp"
852+
android:layout_height="150dp"
853+
android:layout_gravity="center_horizontal"
854+
android:layout_marginTop="16dp"
855+
android:gravity="bottom|center"
856+
android:paddingBottom="1dp"
857+
android:text="网络背景图"
858+
android:textColor="#000"
859+
android:textSize="14sp"
860+
app:stv_corner="10dp"
861+
app:stv_isShowState="true"
862+
app:stv_drawableAsBackground="true"
863+
app:stv_solid="#f1f1f1"
864+
app:stv_state_drawable="https://gw.alicdn.com/imgextra/i3/O1CN01suhAFr1cXQX49D2xp_!!6000000003610-0-tps-468-466.jpg" />
865+
866+
<com.coorchice.library.SuperTextView
867+
android:id="@+id/stv_41"
868+
android:layout_width="350dp"
869+
android:layout_height="100dp"
870+
android:layout_gravity="center_horizontal"
871+
android:layout_marginTop="30dp"
872+
android:paddingLeft="116dp"
873+
android:paddingTop="30dp"
874+
android:text="StateDrawable2 网络图"
875+
android:textColor="@color/black"
876+
android:textSize="14sp"
877+
app:stv_corner="50dp"
878+
app:stv_isShowState2="true"
879+
app:stv_left_bottom_corner="true"
880+
app:stv_left_top_corner="true"
881+
app:stv_solid="#f1f1f1"
882+
app:stv_state_drawable2="https://gw.alicdn.com/imgextra/i3/O1CN01XPmcmt1vJfKcQ8o6O_!!6000000006152-0-tps-500-500.jpg"
883+
app:stv_state_drawable2_height="100dp"
884+
app:stv_state_drawable2_mode="left"
885+
app:stv_state_drawable2_width="100dp"
886+
tools:stv_state_drawable2="@drawable/avatar3" />
887+
841888
<!--Next-->
842889
<com.coorchice.library.SuperTextView
843890
android:id="@+id/btn_next"

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?><!--
2+
~ Copyright (C) 2021 CoorChice <[email protected]>
3+
~ <p>
4+
~ Licensed under the Apache License, Version 2.0 (the "License");you may not use this file except
5+
~ in compliance with the License. You may obtain a copy of the License at
6+
~ <p>
7+
~ http://www.apache.org/licenses/LICENSE-2.0
8+
~ <p>
9+
~ Unless required by applicable law or agreed to in writing, software distributed under the License
10+
~ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11+
~ or implied. See the License for the specific language governing permissions and limitations under
12+
~ the License.
13+
~ <p>
14+
~ Last modified 3/25/21 4:04 PM
15+
-->
16+
17+
<com.coorchice.library.SuperTextView xmlns:android="http://schemas.android.com/apk/res/android"
18+
xmlns:app="http://schemas.android.com/apk/res-auto"
19+
android:layout_width="wrap_content"
20+
android:layout_height="wrap_content"/>

0 commit comments

Comments
 (0)