GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — 进度条优化 · tinyrobbert/AndroidCustomView@bb13e5a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • app/src/main
    • java/com/allen/androidcustomview
      • activity
        • ProgressBarActivity.java
      • widget
        • CircleProgressBarView.java
        • HorizontalProgressBar.java
    • res/layout
      • activity_pregress_bar.xml
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎app/src/main/java/com/allen/androidcustomview/activity/ProgressBarActivity.java‎

Copy file name to clipboardExpand all lines: app/src/main/java/com/allen/androidcustomview/activity/ProgressBarActivity.java
+20-2Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import android.support.v7.app.AppCompatActivity;
44
import android.os.Bundle;
5+
import android.view.View;
6+
import android.widget.Button;
57
import android.widget.TextView;
68
import android.widget.Toast;
79

@@ -15,6 +17,7 @@ public class ProgressBarActivity extends AppCompatActivity {
1517
HorizontalProgressBar horizontalProgressBar;
1618
TextView textView;
1719

20+
Button button;
1821
@Override
1922
protected void onCreate(Bundle savedInstanceState) {
2023
super.onCreate(savedInstanceState);
@@ -25,8 +28,9 @@ protected void onCreate(Bundle savedInstanceState) {
2528
horizontalProgressBar = (HorizontalProgressBar) findViewById(R.id.horizontal_progress_view);
2629

2730
textView = (TextView) findViewById(R.id.progress_tv);
31+
button = (Button) findViewById(R.id.startAnimationBtn);
2832

29-
circleProgressBarView.setProgress(70);
33+
circleProgressBarView.setProgress(60);
3034
circleProgressBarView.setProgressListener(new CircleProgressBarView.ProgressListener() {
3135
@Override
3236
public void currentProgressListener(float currentProgress) {
@@ -35,13 +39,27 @@ public void currentProgressListener(float currentProgress) {
3539
});
3640
circleProgressBarView.startProgressAnimation();
3741

38-
horizontalProgressBar.setProgress(98).setProgressListener(new HorizontalProgressBar.ProgressListener() {
42+
horizontalProgressBar.setProgress(60).setProgressListener(new HorizontalProgressBar.ProgressListener() {
3943
@Override
4044
public void currentProgressListener(float currentProgress) {
4145
}
4246
});
4347
horizontalProgressBar.startProgressAnimation();
4448

49+
50+
button.setOnClickListener(new View.OnClickListener() {
51+
@Override
52+
public void onClick(View v) {
53+
horizontalProgressBar.setProgress(60);
54+
circleProgressBarView.setProgress(60).startProgressAnimation();
55+
circleProgressBarView.setProgressListener(new CircleProgressBarView.ProgressListener() {
56+
@Override
57+
public void currentProgressListener(float currentProgress) {
58+
textView.setText("当前进度:" + currentProgress);
59+
}
60+
});
61+
}
62+
});
4563
}
4664

4765
@Override
Collapse file

‎app/src/main/java/com/allen/androidcustomview/widget/CircleProgressBarView.java‎

Copy file name to clipboardExpand all lines: app/src/main/java/com/allen/androidcustomview/widget/CircleProgressBarView.java
+9-3Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,14 @@ public class CircleProgressBarView extends View {
5454
*/
5555
private Paint progressPaint;
5656

57-
private int circleBgColor = Color.GRAY;
58-
private int progressColor = Color.RED;
57+
/**
58+
* 进度条背景颜色
59+
*/
60+
private int circleBgColor = 0xFFe1e5e8;
61+
/**
62+
* 进度条颜色
63+
*/
64+
private int progressColor = 0xFFf66b12;
5965

6066
/**
6167
* 默认圆环的宽度
@@ -84,7 +90,7 @@ public class CircleProgressBarView extends View {
8490
/**
8591
* 动画执行时间
8692
*/
87-
private int duration = 2000;
93+
private int duration = 1000;
8894
/**
8995
* 动画延时启动时间
9096
*/

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.