Skip to content

Commit

Permalink
Update to v1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
liqiang2 committed Dec 24, 2021
1 parent 3ce62f6 commit 2977e39
Show file tree
Hide file tree
Showing 18 changed files with 425 additions and 5 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ allprojects {
```groovy
dependencies {
...
implementation 'com.github.liqvip:EasyView:1.0.0'
implementation 'com.github.liqvip:EasyView:1.0.1'
}
```

Expand Down Expand Up @@ -101,10 +101,16 @@ dependencies {
| setBottomLeftRadius(dp: Float) | 设置左下方圆角半径 | ev_bottomLeft_radius |
| setStrokeWidth(dp: Float) | 设置描边宽度 | ev_stroke_width |
| setStrokeColor(color: Int) | 设置描边颜色 | ev_stroke_color |
| setStrokeColor(argb: String) | 设置描边颜色 | ev_stroke_color |
| setStrokeWidthColor(widthDp: Float, color: Int) | 同时设置描边宽度和颜色 | ev_stroke_width,ev_stroke_color |

### 在真机上运行测试
读者可以在手机上运行此项目,动态设置 View 的圆角、描边等属性,感受实际效果。下面是运行截图。
![](images/demo/demo_test.png)

### 版本记录
| 版本号 | 更新内容 | 备注 |
|--------|--------------|--------------|
| v1.0.1 | 1. 增加真机测试界面 2. 修复代码动态设置描边不生效的问题 | 请使用 v1.0.1 版本,避免动态设置描边不生效 |
| v1.0.0 | First commit | First commit |

13 changes: 11 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,19 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" >
<activity android:name=".MainActivity" >
<intent-filter>
<activity android:name=".MainActivity"
android:launchMode="singleTask">
<!--<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>-->
</activity>

<activity
android:name=".TestActivity"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Expand Down
144 changes: 144 additions & 0 deletions app/src/main/java/com/github/easyview/demo/TestActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
package com.github.easyview.demo

import android.os.Bundle
import android.text.TextUtils
import android.view.View
import android.widget.Button
import android.widget.EditText
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.github.easyview.EasyView

/**
* @author: Little Bei
* @Date: 2021/12/24
*/
class TestActivity: AppCompatActivity(), View.OnClickListener {

private lateinit var easyView: EasyView

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_test)

initView()
}

private fun initView() {
easyView = findViewById(R.id.ev)


findViewById<Button>(R.id.bt_left).setOnClickListener(this)
findViewById<Button>(R.id.bt_top).setOnClickListener(this)
findViewById<Button>(R.id.bt_right).setOnClickListener(this)
findViewById<Button>(R.id.bt_bottom).setOnClickListener(this)

findViewById<Button>(R.id.bt_top_left).setOnClickListener(this)
findViewById<Button>(R.id.bt_top_right).setOnClickListener(this)
findViewById<Button>(R.id.bt_bottom_right).setOnClickListener(this)
findViewById<Button>(R.id.bt_bottom_left).setOnClickListener(this)

findViewById<Button>(R.id.bt_all_radius).setOnClickListener(this)
findViewById<Button>(R.id.bt_stroke_width).setOnClickListener(this)
findViewById<Button>(R.id.bt_stroke_color).setOnClickListener(this)
}

override fun onClick(v: View) {
when(v.id) {
R.id.bt_left -> {
val left = findViewById<EditText>(R.id.et_left).text
if(TextUtils.isEmpty(left) || !TextUtils.isDigitsOnly(left)){
Toast.makeText(this, "请输入正确的圆角半径!", Toast.LENGTH_SHORT).show()
}else{
easyView.setLeftRadius(left.toString().toFloat())
}
}
R.id.bt_top -> {
val left = findViewById<EditText>(R.id.et_top).text
if(TextUtils.isEmpty(left) || !TextUtils.isDigitsOnly(left)){
Toast.makeText(this, "请输入正确的圆角半径!", Toast.LENGTH_SHORT).show()
}else{
easyView.setTopRadius(left.toString().toFloat())
}
}
R.id.bt_right -> {
val left = findViewById<EditText>(R.id.et_right).text
if(TextUtils.isEmpty(left) || !TextUtils.isDigitsOnly(left)){
Toast.makeText(this, "请输入正确的圆角半径!", Toast.LENGTH_SHORT).show()
}else{
easyView.setRightRadius(left.toString().toFloat())
}
}
R.id.bt_bottom -> {
val left = findViewById<EditText>(R.id.et_bottom).text
if(TextUtils.isEmpty(left) || !TextUtils.isDigitsOnly(left)){
Toast.makeText(this, "请输入正确的圆角半径!", Toast.LENGTH_SHORT).show()
}else{
easyView.setBottomRadius(left.toString().toFloat())
}
}


R.id.bt_top_left -> {
val left = findViewById<EditText>(R.id.et_top_left).text
if(TextUtils.isEmpty(left) || !TextUtils.isDigitsOnly(left)){
Toast.makeText(this, "请输入正确的圆角半径!", Toast.LENGTH_SHORT).show()
}else{
easyView.setTopLeftRadius(left.toString().toFloat())
}
}
R.id.bt_top_right -> {
val left = findViewById<EditText>(R.id.et_top_right).text
if(TextUtils.isEmpty(left) || !TextUtils.isDigitsOnly(left)){
Toast.makeText(this, "请输入正确的圆角半径!", Toast.LENGTH_SHORT).show()
}else{
easyView.setTopRightRadius(left.toString().toFloat())
}
}
R.id.bt_bottom_right -> {
val left = findViewById<EditText>(R.id.et_bottom_right).text
if(TextUtils.isEmpty(left) || !TextUtils.isDigitsOnly(left)){
Toast.makeText(this, "请输入正确的圆角半径!", Toast.LENGTH_SHORT).show()
}else{
easyView.setBottomRightRadius(left.toString().toFloat())
}
}
R.id.bt_bottom_left -> {
val left = findViewById<EditText>(R.id.et_bottom_left).text
if(TextUtils.isEmpty(left) || !TextUtils.isDigitsOnly(left)){
Toast.makeText(this, "请输入正确的圆角半径!", Toast.LENGTH_SHORT).show()
}else{
easyView.setBottomLeftRadius(left.toString().toFloat())
}
}


R.id.bt_all_radius -> {
val left = findViewById<EditText>(R.id.et_all_radius).text
if(TextUtils.isEmpty(left) || !TextUtils.isDigitsOnly(left)){
Toast.makeText(this, "请输入正确的圆角半径!", Toast.LENGTH_SHORT).show()
}else{
easyView.setRadius(left.toString().toFloat())
}
}
R.id.bt_stroke_width -> {
val left = findViewById<EditText>(R.id.et_stroke_width).text
if(TextUtils.isEmpty(left) || !TextUtils.isDigitsOnly(left)){
Toast.makeText(this, "请输入正确的描边大小!", Toast.LENGTH_SHORT).show()
}else{
easyView.setStrokeWidth(left.toString().toFloat())
}
}
R.id.bt_stroke_color -> {
val left = findViewById<EditText>(R.id.et_stroke_color).text
if(TextUtils.isEmpty(left) || !left.startsWith('#') || left.length != 7){
Toast.makeText(this, "请输入正确的描边颜色值,如 '#FFFFFF'", Toast.LENGTH_SHORT).show()
}else{
easyView.setStrokeColor(left.toString())
}
}

}
}

}
190 changes: 190 additions & 0 deletions app/src/main/res/layout/activity_test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<com.github.easyview.EasyView
android:id="@+id/ev"
android:layout_width="@dimen/dp_200"
android:layout_height="@dimen/dp_150"
android:background="@color/demo7"/>

<!--left, top, right, bottom-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_20"
android:orientation="horizontal"
android:gravity="center">
<EditText
android:id="@+id/et_left"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="left"/>
<EditText
android:id="@+id/et_top"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="top"/>
<EditText
android:id="@+id/et_right"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="right"/>
<EditText
android:id="@+id/et_bottom"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="bottom"/>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center">
<Button
android:id="@+id/bt_left"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="确定"/>
<Button
android:id="@+id/bt_top"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="确定"/>
<Button
android:id="@+id/bt_right"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="确定"/>
<Button
android:id="@+id/bt_bottom"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="确定"/>
</LinearLayout>

<!--topLeft, topRight, bottomRight, bottomLeft-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_20"
android:orientation="horizontal"
android:gravity="center">
<EditText
android:id="@+id/et_top_left"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="top_left"/>
<EditText
android:id="@+id/et_top_right"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="top_right"/>
<EditText
android:id="@+id/et_bottom_right"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="bottom_right"/>
<EditText
android:id="@+id/et_bottom_left"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="bottom_left"/>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center">
<Button
android:id="@+id/bt_top_left"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="确定"/>
<Button
android:id="@+id/bt_top_right"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="确定"/>
<Button
android:id="@+id/bt_bottom_right"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="确定"/>
<Button
android:id="@+id/bt_bottom_left"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="确定"/>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_20"
android:orientation="horizontal"
android:gravity="center">
<EditText
android:id="@+id/et_all_radius"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="all_radius"/>
<EditText
android:id="@+id/et_stroke_width"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="stroke_width"/>
<EditText
android:id="@+id/et_stroke_color"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="stroke_color"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center">
<Button
android:id="@+id/bt_all_radius"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="确定"/>
<Button
android:id="@+id/bt_stroke_width"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="确定"/>
<Button
android:id="@+id/bt_stroke_color"
android:layout_width="@dimen/dp_0"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="确定"/>
</LinearLayout>
</LinearLayout>
Loading

0 comments on commit 2977e39

Please sign in to comment.