0
我在滾動視圖中有一個進度條,我想以編程方式修改寬度,但它看起來像不可能,在xml中我只有這樣的進度條:以編程方式更新水平進度條寬度(在水平滾動視圖中)
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ProgressBar
android:id="@+id/progressbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyleHorizontal" />
</HorizontalScrollView>
和代碼也很簡單:
ProgressBar progressBar = (ProgressBar) findViewById(R.id.progressbar);
progressBar.setMinimumWidth(3000);
progressBar.invalidate(); // tried called invalidate although setMinimumWidth called requestLayout, not help
我也試圖設置佈局寬度,像這樣:
progressBar.getLayoutParams().width = 3000;
progressBar.invalidate();
但發現它只適用於不在滾動視圖中的進度條...
任何想法如何更新進度條寬度(在水平滾動視圖中)?以及爲什麼滾動視圖缺陷進度條寬度? 謝謝!
將來,請不要刪除問題,然後重新提出問題。 – CommonsWare
@CommonsWare,我這樣做是因爲原來的問題發生了很大的變化,但得到了你的評論,並且將來不會這樣做。謝謝! – AsfK
「我這樣做是因爲原始問題發生了很大的變化」 - 這就是「編輯」鏈接的作用。 :-) – CommonsWare