gpt4 book ai didi

android - progressBar.setIndeterminateDrawable() 不起作用

转载 作者:太空宇宙 更新时间:2023-11-03 12:56:46 24 4
gpt4 key购买 nike

当我尝试更改我的 indeteminateDrawable 进度条时,它就消失了(我必须为我的进度条更改可绘制对象。我尝试了 invalidate、requestLayout 等。我不知道该如何解决。谢谢…………

这里代码:

progressBar.setIndeterminateDrawable(getResources().getDrawable(R.drawable.‌​progress_indeterminate_horizontal_didnt_like));

progressBar.setIndeterminate(true);

是的。它在 XML 中可见。

 <ProgressBar
android:id="@+id/progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:indeterminate="true"
android:indeterminateDrawable="@drawable/progress_indeterminate_horizontal_to_review" />

  private void showProgressByCategory(String category) {
progressBar = (ProgressBar) findViewById(R.id.progress);


switch (CATEGORY.getPosition(category)) {
case CATEGORY.DIDNT_LIKE_POS:
// Didnt like
progressBar.setIndeterminateDrawable(getResources().getDrawable(
R.drawable.progress_indeterminate_horizontal_didnt_like));

break;
case CATEGORY.TO_SEE_POS:
// To See
progressBar.setIndeterminateDrawable(getResources().getDrawable(
R.drawable.progress_indeterminate_horizontal_to_see));
break;
case CATEGORY.SAW_AND_LIKED_POS:
// Saw And Liked
progressBar.setIndeterminateDrawable(getResources().getDrawable(
R.drawable.progress_indeterminate_horizontal_saw_liked));
break;
case CATEGORY.TO_REVIEW_POS:
// To Review
progressBar.setIndeterminateDrawable(getResources().getDrawable(
R.drawable.progress_indeterminate_horizontal_to_review));

break;
}
progressBar.setIndeterminate(true);
}

最佳答案

你必须在setIndeterminateDrawable()之前调用具有固有尺寸的drawable.setBounds()来解决

关于android - progressBar.setIndeterminateDrawable() 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18743559/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com