Configure EasyView
This is a simple and convenient Android custom View library. I have always had an idea to create an open source library. Now this idea has been implemented. If you have any custom Views you need to put forward, you may not necessarily adopt them. If you are reasonable, you will not be able to adopt them. If the time period is not guaranteed, we must do what we can and be more down-to-earth.
1. Project or Configuration
The code has been pushed toMavenCentral()
,existAndroid Studio 4.2
In future versions, use it when creating a project by default.MavenCentral()
, notjcenter()
。
If it is the previous version, it needs to berepositories{}
Added in closuremavenCentral()
The difference is that the old version of Android Studio is in the projectAdded in, and the new version is engineering
Added inIf you have already added, do not add it repeatedly.
repositories { ... mavenCentral() }
2. Use module configuration
For example, inapp
Used in the module, open the app module,exist
dependencies{}
Just add it under the closure, remember toSync Now
。
dependencies { implementation ':easyview:1.0.2' }
Using EasyView
This is a library for custom Views, which will gradually enrich the custom Views. I will draw a pie first.
1. MacAddressEditText
MacAddressEditText is a Bluetooth Mac address input control. After clicking, a customized Hex keyboard appears to be used to enter values.
1. Used in xml
First, add the following code to the xml, refer to activity_main.xml in the app module for details.
< android: android:layout_width="wrap_content" android:layout_height="wrap_content" app:boxBackgroundColor="@color/white" app:boxStrokeColor="@color/black" app:boxStrokeWidth="2dp" app:boxWidth="48dp" app:separator=":" app:textColor="@color/black" app:textSize="14sp" />
2. Properties introduction
All properties of MacAddressEditText are used here, and you can set them yourself. Please refer to the following table for instructions on use.
property | illustrate |
---|---|
app:boxBackgroundColor | Set the background color of the input box |
app:boxStrokeColor | Set the border color of the input box |
app:boxStrokeWidth | Set the border size of the input box |
app:boxWidth | Set the input box size |
app:separator | Delimiter for Mac addresses, such as semicolons: |
app:textColor | Set the text color of the input box |
app:textSize | Set the text size of the input box |
3. Use in the code
MacAddressEditText macEt = findViewById(.mac_et); String macAddress = ();
macAddress may be an empty string. Please judge before using it, refer to the usage method in MainActivity in the app module.
2. CircularProgressBar
CircularProgressBar is a circle progress bar control.
1. Used in xml
First, add the following code to the xml, refer to activity_main.xml in the app module for details.
< android: android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="30dp" app:maxProgress="100" app:progress="10" app:progressbarBackgroundColor="@color/purple_500" app:progressbarColor="@color/purple_200" app:radius="80dp" app:strokeWidth="16dp" app:text="10%" app:textColor="@color/teal_200" app:textSize="28sp" />
2. Properties introduction
All properties of MacAddressEditText are used here, and you can set them yourself. Please refer to the following table for instructions on use.
property | illustrate |
---|---|
app:maxProgress | Maximum progress |
app:progress | Current progress |
app:progressbarBackgroundColor | Progress bar background color |
app:progressbarColor | Progress color |
app:radius | Radius, used to set the size of the ring |
app:strokeWidth | Progress bar size |
app:text | Progress bar center text |
app:textColor | Progress bar center text color |
app:textSize | Progress bar center text size |
3. Use in the code
CircularProgressBar cpbTest = findViewById(.cpb_test); int progress = 10; (progress + "%"); (progress);
Refer to the usage method in MainActivity in the app module.
3. TimingTextView
TimingTextView is a timed text control
1. Used in xml
First, add the following code to the xml, refer to activity_main.xml in the app module for details.
< android: android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="30dp" android:text="Timed text" android:textColor="@color/black" android:textSize="32sp" app:countdown="false" app:max="60" app:unit="s" />
2. Properties introduction
There are not many custom attributes used here, only 3. The attributes of TextView will not be listed. Please refer to the following table for instructions on use.
property | illustrate |
---|---|
app:countdown | Whether to count down |
app:max | Maximum time length |
app:unit | Time unit: s (seconds), m (minutes), h (hours) |
3. Use in the code
TimingTextView tvTiming = findViewById(.tv_timing); (6);//Maximum time (false);//Is the countdown time (3);//Units of seconds (new TimingListener() { @Override public void onEnd() { //Timed end } }); //Start timing (); //Stop timing //();
Refer to the usage method in MainActivity in the app module.
The above is the detailed content of the Android custom open source library EasyView. For more information about Android custom EasyView, please follow my other related articles!