This article has participated in the “Digitalstar Project” and won a creative gift package to challenge the creative incentive money.

Series of articles

Android Line Wait animation JMWorkProgress


preface

Some friends suggested that Ji meng add the code to Github to improve the readability of the article. So ji Meng created his first dependency library today.


1. Use (add dependency)

maven { url ‘jitpack.io’}

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io'}}}Copy the code

Implementation ‘com. Making. Yufseven: JMWorkProgress: v1.0’

dependencies {
    ...
    implementation 'com. Making. Yufseven: JMWorkProgress: v1.0'
}
Copy the code

Two, common use steps

In the XML call

1. In a style without any other attributes

<com.shenzhen.jimeng.jm.JMWorkProgress
    android:layout_width="200dp"
    android:layout_height="200dp"
    />
Copy the code

Effect:

2. Change the color of the lines

  • Oval_big_color: outermost line (largest)
  • Oval_second_color: indicates the second layer
  • Oval_thirdly_color: third layer
  • Oval_min_color: the fourth layer

Change it to the same color for effect

<com.shenzhen.jimeng.jm.JMWorkProgress
    android:layout_width="200dp"
    android:layout_height="200dp"
    app:oval_big_color="@color/colorAccent"
    app:oval_second_color="@color/colorPrimary"
    app:oval_thirdly_color="@color/colorPrimary"
    app:oval_min_color="@color/colorAccent"
    />
Copy the code

Effect:

3. Change the line width

Key call: app:ovalStrokeWidth

<com.shenzhen.jimeng.jm.JMWorkProgress
    android:layout_width="200dp"
    android:layout_height="200dp"
    app:oval_big_color="@color/colorAccent"
    app:oval_second_color="@color/colorPrimary"
    app:oval_thirdly_color="@color/colorPrimary"
    app:oval_min_color="@color/colorAccent"
    app:ovalStrokeWidth="20"
    />
Copy the code

Effect:

4. Add text

  • App :text: added text
  • App :textSize :textSize (no unit, number is ok)
  • App :textStyle :textStyle (three choices, namely STROKE, FILL, FILL_AND_STROKE)

Note: The font color is the same as the corresponding line color on the left

<com.shenzhen.jimeng.jm.JMWorkProgress
    android:layout_width="200dp"
    android:layout_height="200dp"
    android:layout_centerInParent="true"
    app:oval_big_color="@color/colorAccent"
    app:oval_second_color="@color/colorPrimary"
    app:oval_thirdly_color="@color/colorPrimary"
    app:oval_min_color="@color/colorAccent"
    app:text="Loading"
    app:textSize="40"
    app:textStyle="FILL"
    />
Copy the code

!!!!!!!!! The text length should be in the range of 1-7.

XML callable attributes are shown in the following table

attribute role
oval_big_color Sets the outermost line color
oval_second_color Sets the second layer line color
oval_thirdly_color Set the third layer line color
oval_min_color Sets the innermost line color
ovalStrokeWidth Set line width
text Set the text content, the length of the text in the range of 1-7, the control has been designed text position emissions
textStyle Setting text Styles
ovalStyle Set line Styles
textSize Set font size
ovalStrokeWidth Set line width

Calling a method in Java

The main method role
getmBigColor Get the outermost line color
setmBigColor Sets the outermost line color
getmSecondColor Get the second layer of line color
setmSecondColor Sets the second layer line color
getmThirdlyColor Get the third layer line color
setmThirdlyColor Set the third layer line color
getmMinColor Gets the innermost line color
setmMinColor Sets the innermost line color
ovalStrokeWidth Set line width
getmText Get text content
setmText Set text, the length of text in the range of 1-7, the control has been designed text position emissions
setmTextStyle Setting text Styles
setmOvalStyle Set line Styles
setmTextSize Set font size
setmOvalStrokeWidth Set line width
setTextIsShow Sets whether text is displayed
animationIsShow Sets whether the animation is displayed

Iii. Project address (leave little star (* ̄))

Click to jump to Github