-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
liqiang2
committed
Dec 24, 2021
1 parent
3ce62f6
commit 2977e39
Showing
18 changed files
with
425 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
144 changes: 144 additions & 0 deletions
144
app/src/main/java/com/github/easyview/demo/TestActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) | ||
} | ||
} | ||
|
||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Oops, something went wrong.