Skip to content

Commit

Permalink
1.修改readme
Browse files Browse the repository at this point in the history
2.更新版本
  • Loading branch information
wangdunwei committed Sep 11, 2018
1 parent 0b22d1d commit 36c54cb
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 27 deletions.
114 changes: 88 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,58 @@
[![jCenter](https://img.shields.io/badge/jCenter-0.1.2-red.svg)](https://bintray.com/ayvytr/maven/custom-views/_latestVersion) [![License](https://img.shields.io/badge/License-Apache--2.0%20-blue.svg)](license)
[![jCenter](https://img.shields.io/badge/jCenter-0.2.0-red.svg)](https://bintray.com/ayvytr/maven/custom-views/_latestVersion) [![License](https://img.shields.io/badge/License-Apache--2.0%20-blue.svg)](license)

<h1 id="AndroidCustomViews">AndroidCustomViews</h1>

方便安卓开发者使用和依赖的自定义控件库
方便安卓开发者使用的自定义控件库



## 加入Gradle依赖

implementation 'com.ayvytr:custom-views:0.1.2'


implementation 'com.ayvytr:custom-views:0.2.0'
或者
compile 'com.ayvytr:custom-views:0.2.0'



## 自定义控件列表

1. NumberPickerView 数字选择控件,支持多行和多种选项的自定义控件 [使用方法](#NumberPickerView使用方法 )
1. NumberPickerView 数字选择控件,支持多行和多种选项的数字选择控件 [使用方法](#NumberPickerView)

2. QuickIndexView 通讯录右侧字母索引控件 [使用方法](#QuickIndexView)

3. SuperEditText 可以一键清空,点击图标显示/隐藏密码的EditText [使用方法](#SuperEditText)

4. SingleTextView 单行,居中,文本超出一行尾部省略的TextView

| | | |
| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| <img src="https://github.com/Carbs0126/Screenshot/blob/master/numberpickerview.gif" /> | <img src="https://github.com/Carbs0126/Screenshot/blob/master/numberpickerview1.jpg" /> | <img src="https://github.com/Carbs0126/Screenshot/blob/master/numberpickerview2.jpg" /> |
5. ClearableEditText <font color=red>**0.2.0新加入**</font> 一键清空文本的EditText,直接继承AppCompatEditText [使用方法](#ClearableEditText)

6. PasswordEditText <font color=red>**0.2.0新加入 **</font>点击或触摸显示/隐藏密码的EditText,直接继承AppCompatEditText [使用方法](#PasswordEditText)



2. QuickIndexView 通讯录右侧字母索引控件 [使用方法](#QuickIndexView)
___

<img src="screenshots/QuickIndexView.gif" width="40%" height="40%" />

3. SuperEditText 可以一键清空,点击图标显示/隐藏密码的自定义控件 [使用方法](#SuperEditText)

<img src="screenshots/SuperEditText.gif" width="40%" height="40%" />
## 截图

4. SingleTextView 单行,居中,文本超出一行尾部省略的TextView
| NumberPickerView | NumberPickerView | NumberPickerView |
| :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: |
| ![img](https://github.com/Carbs0126/Screenshot/blob/master/numberpickerview.gif) | ![img](https://github.com/Carbs0126/Screenshot/blob/master/numberpickerview1.jpg) | ![img](https://github.com/Carbs0126/Screenshot/blob/master/numberpickerview2.jpg) |


| QuickIndexView | SuperEditText | ClearableEditText |
| ------------------------------------------------------------ | ------------------------------------------ | -------------------------------------- |
| <img src="screenshots/QuickIndexView.gif" width="50%" height="50%" /> | <img src="screenshots/SuperEditText.gif"/> | ![](screenshots/ClearableEditText.gif) |

___
| PasswordEditText |
| ------------------------------------- |
| ![](screenshots/PasswordEditText.gif) |



## 说明
## 使用和说明

### NumberPickerView
<h3 id="NumberPickerView">NumberPickerView</h3>

`NumberPickerView`是一款与android原生`NumberPicker`具有类似界面以及类似功能的`View`
主要功能同样是从多个候选项中通过上下滚动的方式选择需要的选项,但是与`NumberPicker`相比较,有几个主要不同点,下面是两者的不同之处。
Expand Down Expand Up @@ -99,7 +106,7 @@ OnValueChangeListenerInScrolling//滑动过程中响应value change



<h3 id="NumberPickerView使用方法">NumberPickerView使用方法</h3>
#### NumberPickerView使用方法

1. 通过布局声明NumberPickerView

Expand All @@ -122,8 +129,8 @@ OnValueChangeListenerInScrolling//滑动过程中响应value change

```

1. Java代码中使用:
1)若设置的数据(String[] mDisplayedValues)不会再次改变,可以使用如下方式进行设置:(与NumberPicker的设置方式一致)
3. Java代码中使用:
1)若设置的数据(String[] mDisplayedValues)不会再次改变,可以使用如下方式进行设置:(与NumberPicker的设置方式一致)

```java
picker.setMinValue(minValue);
Expand Down Expand Up @@ -280,9 +287,7 @@ indexArray 字母索引数组





## SuperEditText
<h3 id="SuperEditText">SuperEditText</h3>

#### API文档

Expand Down Expand Up @@ -330,13 +335,70 @@ setText(String text) 设置文本



<h3 id="ClearableEditText">ClearableEditText</h3>

#### API 文档

```java
getClearTextDrawable() 获取清除Drawable
isShowClearDrawableNoFocus() 没有焦点时是否显示清除Drawable
setClearTextDrawable(Drawable clearTextDrawable) 设置清除Drawable
setClearTextDrawable(int drawableId) 设置清除Drawable
setShowClearDrawableNoFocus(boolean showClearDrawableNoFocus) 设置没有焦点时是否显示清除Drawable
```

#### 自定义属性表

```
<declare-styleable name="ClearableEditText">
<attr name="showClearDrawableNoFocus" format="boolean"/> 是否在没有焦点时显示Drawable
</declare-styleable>
```

<h3 id="PasswordEditText">PasswordEditText</h3>

#### API 文档

```
getHidePasswordDrawable() 获取隐藏密码Drawable
getShowPasswordDrawable() 获取显示密码Drawable
isPasswordInputType(int inputType) 判断输入类型是不是密码.
isShowDrawableNoFocus() 获取是否在没有焦点时显示Drawable.
setClickMode(boolean clickMode) 设置点击显示/隐藏Drawable模式
setHidePasswordDrawable(Drawable hidePasswordDrawable) 设置隐藏密码Drawable
setHidePasswordDrawable(int hidePasswordDrawableId) 设置隐藏密码Drawable
setShowDrawableNoFocus(boolean showDrawableNoFocus) 设置是否在没有焦点时显示Drawable
setShowPasswordDrawable(android.graphics.drawable.Drawable showPasswordDrawable) 设置显示密码Drawable
setShowPasswordDrawable(int showPasswordDrawableId) 设置显示密码Drawable
```



#### 自定义属性表

```
<declare-styleable name="PasswordEditText">
<attr name="showPasswordDrawable" format="reference"/> 显示密码Drawable
<attr name="hidePasswordDrawable" format="reference"/> 隐藏密码Drawable
<attr name="showDrawableWhenEmptyText" format="boolean"/> 当文本为空时是否显示Drawable
<attr name="clickMode" format="boolean"/> 点击模式,true:点击显示,再次点击隐藏密码;false:按下显示,抬起隐藏密码
<attr name="showDrawableNoFocus" format="boolean"/> 当没有焦点时是否显示Drawable
</declare-styleable>
```



## TODO

1. SuperEditText自定义属性过多,需要优化和重新设计
1. ~~SuperEditText自定义属性过多,需要优化和重新设计~~
2. 加入更多自定义View
3. 自定义TabLayout
4. 完善测试用例(欢迎熟练Espresso等测试的大神提意见或者推荐资料)



### 想要更多自定义控件请到[顶部](#AndroidCustomViews)提Issue或者Pull Request吧!



## 都看到这儿了,那就点个[Star](#AndroidCustomViews)吧!非常感谢!
## 都看到这儿了,那就请点个[Star](#AndroidCustomViews)吧!非常感谢!
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.View
import com.ayvytr.androidcustomviews.R
import com.ayvytr.customview.custom.text.ClearableEditText
import kotlinx.android.synthetic.main.activity_clearable_edit_text.*
import org.jetbrains.anko.sdk25.coroutines.onClick

Expand All @@ -15,6 +16,7 @@ class ClearableEditTextActivity : AppCompatActivity() {
}

private fun initView() {
setTitle(ClearableEditText::class.java.simpleName)
et.onFocusChangeListener = View.OnFocusChangeListener { v, hasFocus -> tvFocus.text = "是否获得焦点:$hasFocus" }
btnChangeDrawable.onClick {
et.setClearTextDrawable(android.R.drawable.ic_menu_search)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.support.v7.app.AppCompatActivity
import android.view.View

import com.ayvytr.androidcustomviews.R
import com.ayvytr.customview.custom.text.PasswordEditText
import kotlinx.android.synthetic.main.activity_password_edit_text.*
import org.jetbrains.anko.sdk25.coroutines.onClick

Expand All @@ -16,6 +17,7 @@ class PasswordEditTextActivity : AppCompatActivity() {
}

private fun initView() {
title = PasswordEditText::class.java.simpleName
btnChangeDrawable.onClick {
et.setShowPasswordDrawable(android.R.drawable.ic_menu_search)
et.setHidePasswordDrawable(android.R.drawable.ic_menu_save)
Expand Down
2 changes: 1 addition & 1 deletion custom-views/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ PROJ_GROUP=com.ayvytr
PROJ_WEBSITEURL=https://github.com/Ayvytr/AndroidCustomViews.git
PROJ_ISSUETRACKERURL=https://github.com/Ayvytr/AndroidCustomViews/issues
PROJ_VCSURL=https://github.com/Ayvytr/AndroidCustomViews.git
PROJ_VERSION=0.1.2
PROJ_VERSION=0.2.0
PROJ_NAME=custom-views

PROJ_DESCRIPTION=Android Custom Views
Expand Down
Binary file added screenshots/ClearableEditText.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/PasswordEditText.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 36c54cb

Please sign in to comment.