我需要在主屏幕小部件中放置垂直滾動條,並且經過多次搜索後,我無法找到適用於API3及更高版本的便捷解決方案!Android:如何將垂直進度條添加到主屏幕小部件?
我嘗試了許多解決方案: - 使用在運行時創建的位圖,但在某些顯示它永遠不會達到100% - 一個patch9位圖,但滾動條顯示得到完全搞砸時進度接近0。 - 使用addView()與100現有的佈局,它的工程很好,除了它只有API7以後纔可用! - 包括所有100個佈局,並且一次只顯示一個佈局,工作正常,但在8種不同的佈局佈局中包含這些佈局真是太麻煩!
我試圖以編程方式使用權重,但它不可能,任何其他解決方案來調整基於%的視圖的大小?
下面是一個進度條的佈局我目前使用的:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<ImageView android:layout_weight="11" android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<ImageView android:src="@drawable/scale"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:layout_weight="89" />
</LinearLayout>
我不是在尋找一個滾動視圖,而是一個垂直進度條,我可以在運行時設置它來表示電池電量(或其他數據)。現在,我使用上面的100個佈局文件來匹配從0%到100%的進度條。非常沉重,至少它有效,但不能改變顏色。 – 3c71