I. Function introduction

To give you a more intuitive idea of what BEditText can do, here is a list of features to briefly describe; As follows:

function describe
Rounded corners The rounded Angle can be set uniformly or the four corners can be set separately
stroke You can set stroke size, color, and hide any edge
shadow You can set the shadow size, color, offset, distance, unilateral and multilateral display, etc
gradient You can set text gradient, background gradient
Auxiliary function Supports one-click clearing

Support content visibility toggle & custom ICONS

Support for setting around ICONS & custom width and height

Support input method control
Alternative style Payment password input style, verification code input style, etc

The following details how to use each function:

In pieces rounded corners

XML setup Code sets describe
app:roundRadius=”10dp” setRoundradius(int radius) Set the four corners with the highest priority
app:topLeftRadius=”10dp” setTopLeftRoundRadius(int radius) Top left rounded corner value
app:topRightRadius=”10dp” setTopRightRoundRadius(int radius) Rounded corner value in upper right corner
app:bottomLeftRadius=”10dp” setBottomLeftRoundRadius(int radius) Lower left corner value
app:bottomRightRadius=”10dp” setBottomRightRoundRadius(int radius) Lower left corner value

If roundRadius is set, the four angles are reset by default

  <! -- All four rounded corners are 10dp-->
  <com.bary.ui.view.BEditText
        .
        app:roundRadius="10dp"
  />
  <! -- Upper left, upper right, sit down rounded corner 10dp-->
  <com.bary.ui.view.BEditText
        .
        app:topLeftRadius="10dp"
        app:topRightRadius="10dp"
        app:bottomLeftRadius="10dp"
  />
Copy the code


Mixer stroke

XML setup Code sets describe
app:borderSize=”3dp” setBorderSize(float size) Sets stroke size
app:borderColor=”#ff8585″ setBorderColor(int color) Sets stroke color
app:borderHideEdges=”left|top” hideBorderEdges(int… edges) Set the edge to be hidden with the value:

Left, top, right, bottom;

Can set up multiple use | space at the same time

(If the code is set,

HideBorderEdges method for

Variable parameters, multiple parameters can be transmitted;

BorderBuilder. LEFT,

BorderBuilder. TOP,

BorderBuilder. RIGHT,

BorderBuilder. BOTTOM)

To display the stroke borderShow must be true

  <com.bary.ui.view.BEditText
        .
        app:borderSize="3dp"
        app:borderColor="#ff8585"
        app:borderHideEdges="left|top"
  />
Copy the code


In pieces the shadow

XML setup Code sets describe
app:shadowShow=”true” setShadowShow(boolean show) Sets whether to show shadows
app:shadowSize=”3dp” setShadowSize(float size) Set the shadow size to the highest priority
app:shadowXSize=”3dp” setShadowXSize(float size) Horizontal shadow size can be set separately
app:shadowYSize=”3dp” setShadowYSize(float size) Vertical shadow size can be set separately
app:shadowDx=”1dp” setShadowDx(float dx) Set the offset for landscape, default 0

View in center, left and right shadow size

The same
app:shadowDy=”1dp” setShadowDy(float dy) Set the vertical offset value. Default is 0

View in center, upper and lower shadow size

The same
app:shadowColor=”#ff8585″ setShadowColor(int color) Set the shadow color
App: shadowAlpha = “0.8” setShadowAlpha(float alpha) Set shadow transparency
app:shadowHideEdges=”left|top” hideShadowEdges(int… edges) Set the edge to be hidden with the value:

Left, top, right, bottom;

Can set up multiple use | space at the same time

(If the code is set,

HideShadowEdges method for

Variable parameters, multiple parameters can be transmitted;

ShadowBuilder. LEFT,

ShadowBuilder. TOP,

ShadowBuilder. RIGHT,

ShadowBuilder. BOTTOM)

ShadowShow must be set to true if you want to display the stroke shadowShow. If shadowSize is set, the default value of shadowXSize will be reset. ShadowYSize will be used as shadowSize. Just set shadowXSize, shadowYSize.

  <com.bary.ui.view.BEditText
        .
        app:shadowShow="true"
        app:shadowSize="3dp"
        app:shadowDx="1dp"
        app:shadowDy="1dp"
        app:shadowColor="#ff8585"
        app:shadowAlpha="0.8"
        app:shadowHideEdges="left|top"
  />
Copy the code


Mixer gradients

XML setup Code sets describe
app:backgroundGradientColor=”#FF8585|#FF8B15″ setBackgroundGradientColor(String… colors) Set background gradient to at least two hexadecimal color values;

The code setting method is indeterminate, pass more than one parameter hexadecimal color value
app:backgroundGradientType=”linear” setBackgroundGradientType

(GradientType type)
Set the gradient type to:

Linear – linear

Radial ring –

Sweep Angle –

————————-

GradientType. LINEAR,

GradientType. RADIAL,

GradientType.SWEEP
app:backgroundGradientOrientation=”horizontal” setBackgroundGradientOrientation

(GradientOrientation orientation)
Set the gradient direction as follows:

Horizontal and vertical

Vertical – horizontal

Diagonal Angle

————————-

GradientOrientation. HORIZONTAL,

GradientOrientation. VERTICAL,

GradientOrientation.DIAGONAL
app:textGradientColor=”#FF8585|#FF8B15″ setBackgroundGradientColor(String… colors) Set background gradient to at least two hexadecimal color values;

The code setting method is indeterminate, pass more than one parameter hexadecimal color value
app:textGradientType=”linear” setTextGradientType

(GradientType type)
Set the gradient type to the same parameter as the background gradient type
app:textGradientOrientation=”horizontal” setTextGradientOrientation

(GradientOrientation orientation)
Set the gradient direction with the same parameters as the background gradient type

When changing colors, you need to set more than one color under the same attribute. Therefore, you can only set hexadecimal color values. You cannot use the Color resource background gradient under Color:

  <com.bary.ui.view.BEditText
        .
        app:backgroundGradientColor="#FF8585|#FF8B15"
        app:backgroundGradientType="linear"
        app:backgroundGradientOrientation="horizontal"

  />
Copy the code

Text gradient:

  <com.bary.ui.view.BEditText
        .
        app:textGradientColor="#FF8585|#FF8B15"
        app:textGradientType="linear"
        app:textGradientOrientation="horizontal"

  />
Copy the code


Auxiliary functions

1. One-click clearing

It has a one-click clearing function, which automatically displays the content in the text box, and can set the display/hide, and the icon can be replaced. Specific instructions are as follows:

XML setup Code sets describe
app:showClearIcon=”true” showClearIcon(boolean show) Sets whether to display a one-click clear icon. Default is true
app:clearIcon=”@drawable/clear” setClearIcon(int res) Set the one-click clear button icon

###### 2. Content visibility toggle & custom ICONS
Support custom content visible button function, hidden by default, can be set to show/hide, ICONS can be replaced; Specific instructions are as follows:
XML setup Code sets describe
app:showSecretIcon=”false” showSecretIcon(boolean show) Sets whether to display the content visible control icon. Default is false
app:secretIconVisible=”@drawable/visible”

app:secretIcoInvisible=”@drawable/invisible”
setSecretIcon(int visibe, int invisibe) Set the content hide button icon

3. Add left and right ICONS & custom width and height
XML setup Code sets describe
app:leftIcon=”@drawable/icon”

app:leftIconWidth=”20dp”

app:leftIconHeight=”20dp”

app:leftIconPadding=”5dp”
addLeftIcon(

Drawable drawable,

int width,

int height,

int padding,

OnClickListener listener

)
Add left icon, code to add support for multiple
Same as above (left-right) addRightIcon .

Note: 1, XML Settings icon around two respective function set a, click event through code set setOnLeftIconClickListener, setOnRightIconClickListener to implement. 2. You can add multiple ICONS on both sides of the code, directly with click events.

4. Input method control

Edit mode can be set, default common mode [Common mode] [Non-editable mode] [editable non-play input method] (with cursor, generally used for voice input)


Tips:
AddTextChangedListener - addNewTextChangedListener setOnTouchListener -- -- setNewOnTouchListener SetOnFocusChangeListener -- -- setNewOnFocusChangeListenerCopy the code

These listeners need to call new methods to take effect.

Two, use method

Maven {url ‘;jitpack.io’} this code is added to the end of the project’s build.gradle repository

  allprojects {
        repositories {
              ...
              maven { url 'https://jitpack.io'}}}Copy the code
2. Refer to build.gradle in the main program or Module you want to use

  dependencies {
        ...
        implementation 'com. Making. Barystudio: BSuperView: 1.0.4'
  }

Copy the code


BSuperViewIf you find it useful, welcome Star, praise, appreciation O(∩_∩)O


More on thisWhat has accumulated over the years of Android development?】 the project