Skip to content

Commit

Permalink
1.Support for setting 'Network Image' in XML for StateDrawable and St…
Browse files Browse the repository at this point in the history
…ateDrawable2
  • Loading branch information
FliggyAndroid committed Jan 17, 2022
1 parent 94ca8de commit 45dffca
Show file tree
Hide file tree
Showing 8 changed files with 263 additions and 14 deletions.
63 changes: 59 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Hello, Developer!Welcome to use SuperTextView


[![](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)
[![](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)


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

# Special Note💡

- **v3.2.5** support:`armeabi-v7a`
- **v3.2.6** support:`armeabi-v7a`

- **v3.2.5.64** support:`armeabi-v7a``arm64-v8a`
- **v3.2.6.64** support:`armeabi-v7a``arm64-v8a`

- **v3.2.5.99** support:`armeabi-v7a``arm64-v8a``x86`
- **v3.2.6.99** support:`armeabi-v7a``arm64-v8a``x86`

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

# Update Log

## v3.2.6

- Support for setting 'Network Image' in XML for StateDrawable and StateDrawable2

> In XML, use a 'Network Image' as a background image
![](https://gw.alicdn.com/imgextra/i1/O1CN01Pw9Z0U21Ie9BK88T9_!!6000000006962-0-tps-730-344.jpg)

```html
<com.coorchice.library.SuperTextView
android:id="@+id/stv_40"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="16dp"
android:gravity="bottom|center"
android:paddingBottom="1dp"
android:text="网络背景图"
android:textColor="#000"
android:textSize="14sp"
app:stv_corner="10dp"
app:stv_isShowState="true"
app:stv_drawableAsBackground="true"
app:stv_solid="#f1f1f1"
app:stv_state_drawable="https://gw.alicdn.com/imgextra/i3/O1CN01suhAFr1cXQX49D2xp_!!6000000003610-0-tps-468-466.jpg" />
```

> In XML, set the 'Network Image' for StateDrawable2
![](https://gw.alicdn.com/imgextra/i4/O1CN01j3XdIb1LHXK50WtRd_!!6000000001274-0-tps-736-236.jpg)

```html
<com.coorchice.library.SuperTextView
android:id="@+id/stv_41"
android:layout_width="350dp"
android:layout_height="100dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp"
android:paddingLeft="116dp"
android:paddingTop="30dp"
android:text="StateDrawable2 网络图"
android:textColor="@color/black"
android:textSize="14sp"
app:stv_corner="50dp"
app:stv_isShowState2="true"
app:stv_left_bottom_corner="true"
app:stv_left_top_corner="true"
app:stv_solid="#f1f1f1"
app:stv_state_drawable2="https://gw.alicdn.com/imgextra/i3/O1CN01XPmcmt1vJfKcQ8o6O_!!6000000006152-0-tps-500-500.jpg"
app:stv_state_drawable2_height="100dp"
app:stv_state_drawable2_mode="left"
app:stv_state_drawable2_width="100dp"/>
```

## v3.2.5

- 【fix】 `stv_pressBgColor` invalid
Expand Down
62 changes: 58 additions & 4 deletions README_CN.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 你好, 开发者!欢迎使用 SuperTextView


[![](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)
[![](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)


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

# 特别提示💡

- **v3.2.5** 版本支持:`armeabi-v7a`
- **v3.2.6** 版本支持:`armeabi-v7a`

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

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

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


# 近期更新

## v3.2.6

- 支持在 XML 中,为 StateDrawable 和 StateDrawable2 设置网络图片

> 在 XML 中,把网络图片作为背景图
![](https://gw.alicdn.com/imgextra/i1/O1CN01Pw9Z0U21Ie9BK88T9_!!6000000006962-0-tps-730-344.jpg)

```html
<com.coorchice.library.SuperTextView
android:id="@+id/stv_40"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="16dp"
android:gravity="bottom|center"
android:paddingBottom="1dp"
android:text="网络背景图"
android:textColor="#000"
android:textSize="14sp"
app:stv_corner="10dp"
app:stv_isShowState="true"
app:stv_drawableAsBackground="true"
app:stv_solid="#f1f1f1"
app:stv_state_drawable="https://gw.alicdn.com/imgextra/i3/O1CN01suhAFr1cXQX49D2xp_!!6000000003610-0-tps-468-466.jpg" />
```

> 在 XML 中,为 StateDrawable2 设置网络图片
![](https://gw.alicdn.com/imgextra/i4/O1CN01j3XdIb1LHXK50WtRd_!!6000000001274-0-tps-736-236.jpg)

```html
<com.coorchice.library.SuperTextView
android:id="@+id/stv_41"
android:layout_width="350dp"
android:layout_height="100dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp"
android:paddingLeft="116dp"
android:paddingTop="30dp"
android:text="StateDrawable2 网络图"
android:textColor="@color/black"
android:textSize="14sp"
app:stv_corner="50dp"
app:stv_isShowState2="true"
app:stv_left_bottom_corner="true"
app:stv_left_top_corner="true"
app:stv_solid="#f1f1f1"
app:stv_state_drawable2="https://gw.alicdn.com/imgextra/i3/O1CN01XPmcmt1vJfKcQ8o6O_!!6000000006152-0-tps-500-500.jpg"
app:stv_state_drawable2_height="100dp"
app:stv_state_drawable2_mode="left"
app:stv_state_drawable2_width="100dp"/>
```
## v3.2.5

- 修复 `stv_pressBgColor` 失效
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import com.coorchice.library.OnDrawableClickedListenerAdapter;
import com.coorchice.library.SuperTextView;
import com.coorchice.library.gifdecoder.GifCache;
import com.coorchice.library.gifdecoder.GifDrawable;
import com.coorchice.library.utils.STVUtils;
import com.coorchice.library.utils.ThreadPool;
Expand Down Expand Up @@ -52,6 +53,7 @@ private void initView() {

if (stv_1.getDrawable() instanceof GifDrawable) {
GifDrawable gifDrawable = (GifDrawable) stv_1.getDrawable();
gifDrawable.play();
// gifDrawable.setFrameDuration(25);
}

Expand Down
22 changes: 22 additions & 0 deletions app/src/main/java/com/coorchice/supertextview/TestActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import android.graphics.drawable.ColorDrawable;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -43,6 +46,7 @@ public class TestActivity extends ActionBarActivity {
private SuperTextView stv_0;
private SuperTextView stv_1;
private ImageView img_gif;
private LinearLayout rootView;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -100,10 +104,28 @@ public void onDrawable1Clicked(SuperTextView stv) {
//
// }
// });
SuperTextView stv = (SuperTextView) LayoutInflater.from(this).inflate(R.layout.stv, rootView, false);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(300, 100);
params.setMargins(100, 50, 0 , 100);
stv.setLayoutParams(params);
stv.setTextColor(Color.parseColor("#666666"));
stv.setSolid(Color.parseColor("#FFFDF4"));
stv.setTextSize(11);
stv.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);
stv.setShowState(true);
stv.setUrlImage("https://gw.alicdn.com/tfs/TB1PWPqtCzqK1RjSZFLXXcn2XXa-160-96.png", false);
// stv.setDrawableTint(SuperTextView.NO_COLOR);
// stv.setDrawableRotate(SuperTextView.NO_ROTATE);
stv.setStateDrawableMode(SuperTextView.DrawableMode.TOP);
stv.setDrawableWidth(36);
stv.setDrawableHeight(36);
stv.setText("IconText");
rootView.addView(stv);
}


private void findViews() {
rootView = (LinearLayout) findViewById(R.id.ll_root);
// stv_0 = (SuperTextView) findViewById(R.id.stv_0);
stv_1 = (SuperTextView) findViewById(R.id.stv_1);
img_gif = (ImageView) findViewById(R.id.img_gif);
Expand Down
47 changes: 47 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,53 @@
app:stv_state_drawable_padding_left="5dp"
app:stv_state_drawable_width="40dp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:text="使用网络图片"
android:textSize="20sp" />

<com.coorchice.library.SuperTextView
android:id="@+id/stv_40"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="16dp"
android:gravity="bottom|center"
android:paddingBottom="1dp"
android:text="网络背景图"
android:textColor="#000"
android:textSize="14sp"
app:stv_corner="10dp"
app:stv_isShowState="true"
app:stv_drawableAsBackground="true"
app:stv_solid="#f1f1f1"
app:stv_state_drawable="https://gw.alicdn.com/imgextra/i3/O1CN01suhAFr1cXQX49D2xp_!!6000000003610-0-tps-468-466.jpg" />

<com.coorchice.library.SuperTextView
android:id="@+id/stv_41"
android:layout_width="350dp"
android:layout_height="100dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp"
android:paddingLeft="116dp"
android:paddingTop="30dp"
android:text="StateDrawable2 网络图"
android:textColor="@color/black"
android:textSize="14sp"
app:stv_corner="50dp"
app:stv_isShowState2="true"
app:stv_left_bottom_corner="true"
app:stv_left_top_corner="true"
app:stv_solid="#f1f1f1"
app:stv_state_drawable2="https://gw.alicdn.com/imgextra/i3/O1CN01XPmcmt1vJfKcQ8o6O_!!6000000006152-0-tps-500-500.jpg"
app:stv_state_drawable2_height="100dp"
app:stv_state_drawable2_mode="left"
app:stv_state_drawable2_width="100dp"
tools:stv_state_drawable2="@drawable/avatar3" />

<!--Next-->
<com.coorchice.library.SuperTextView
android:id="@+id/btn_next"
Expand Down
20 changes: 20 additions & 0 deletions app/src/main/res/layout/stv.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (C) 2021 CoorChice <icechen_@outlook.com>
~ <p>
~ Licensed under the Apache License, Version 2.0 (the "License");you may not use this file except
~ in compliance with the License. You may obtain a copy of the License at
~ <p>
~ http://www.apache.org/licenses/LICENSE-2.0
~ <p>
~ Unless required by applicable law or agreed to in writing, software distributed under the License
~ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
~ or implied. See the License for the specific language governing permissions and limitations under
~ the License.
~ <p>
~ Last modified 3/25/21 4:04 PM
-->

<com.coorchice.library.SuperTextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
Loading

1 comment on commit 45dffca

@Darkuglyfate
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy , really like

Please sign in to comment.