Android progressBar不显示或不可见
我的自定义进度条不显示。我在我的活动中为它设置动画,并使用可绘制的资源文件。这是我的密码 Activity.javaAndroid progressBar不显示或不可见,android,progress-bar,android-progressbar,Android,Progress Bar,Android Progressbar,我的自定义进度条不显示。我在我的活动中为它设置动画,并使用可绘制的资源文件。这是我的密码 Activity.java ProgressBar progressBar; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); pro
ProgressBar progressBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
progressBar = findViewById(R.id.progressBar);
ObjectAnimator animation = ObjectAnimator.ofInt(progressBar, "progress",
0, 500);
animation.setDuration(5000); // in milliseconds
animation.setInterpolator(new DecelerateInterpolator());
animation.start();
activity.xml
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:max="500"
android:progress="0"
android:progressDrawable="@drawable/circular"
app:layout_constraintBottom_toBottomOf="@+id/relativeLayout"
app:layout_constraintEnd_toEndOf="@+id/relativeLayout"
app:layout_constraintHorizontal_bias="0.475"
app:layout_constraintStart_toStartOf="@+id/relativeLayout"
app:layout_constraintTop_toTopOf="@+id/relativeLayout"
app:layout_constraintVertical_bias="0.153" />
drawableResource.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:useLevel="true"
android:indeterminate="true"
android:innerRadiusRatio="2.3"
android:shape="ring"
android:thickness="3.8sp" >
<solid android:color="@color/colorPrimary" />
</shape>
正是您想要的
在渐变中添加此依赖项
dependencies {
implementation 'com.github.lzyzsd:circleprogress:1.2.1' // or compile for old versions gradle
}
在您的项目级别build.gradle
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
在你的布局中添加这个
<com.github.lzyzsd.circleprogress.DonutProgress
android:layout_marginLeft="50dp"
android:id="@+id/donut_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
custom:donut_progress="30"/>
有关更多自定义信息,请参阅
代码应以文本格式发布,而不是图像!我更新了我的问题…请现在就看。我正在等待你的解决方案谢谢@Khemraj。你能看一下这个问题吗?我已经在里面呆了2天了。我是新来的堆栈溢出。你能显示你需要的UI吗?@Khemraj我在我的帖子中添加了图像…方形区域中的区域我需要我的进度条