最简单的圆形进度条控件,支持自定义颜色、边框、背景等属性。
首先,你需要导入模块项目或者添加依赖类库:
build.gradle(Project)
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
build.gradle(Module:app)
dependencies {
compile 'com.github.Ccapton:CircleProgressBar:1.1.0'
}
<online.osslab.CircleProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
circle:background_color="#FFCDD2"
circle:background_width="5dp"
circle:progress_color="#F44336"
circle:progress_width="10dp" />
当然,你还可以通过以下属性个性化圆形图像样式。
circle:max_value
(integer) -> 150circle:progress_value
(integer) -> 0circle:progressbar_color
(color) -> BLACKcircle:background_color
(color) -> GRAYcircle:progress_width
(dimension) -> 7dpcircle:background_width
(dimension) -> 3dp
CircleProgressBar circleProgressBar = (CircleProgressBar )findViewById(R.id.myCircleProgressBar );
circleProgressBar.setColor(ContextCompat.getColor(this, R.color.progressBarColor));
circleProgressBar.setBackgroundColor(ContextCompat.getColor(this, R.color.backgroundProgressBarColor));
circleProgressBar.setProgressBarWidth(getResources().getDimension(R.dimen.progressBarWidth));
circleProgressBar.setBackgroundProgressBarWidth(getResources().getDimension(R.dimen.backgroundProgressBarWidth));
int animationDuration = 2500; // 2500ms = 2,5s
circleProgressBar.setProgressWithAnimation(65, animationDuration); // Default duration = 1500ms
Copyright 2016 Lopez Mikhae
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.