當前位置:首頁 » 安卓系統 » publicxmlandroid

publicxmlandroid

發布時間: 2024-01-26 09:20:21

『壹』 android progressbar的白色背景怎麼去掉

下面這個圖片是progressbar的各種樣式,不知道能不能滿足您的要求,例子來自於android學習手冊,360手機助手中可以下載,裡面有108個android例子,點擊源碼可以看源碼,點擊文檔可以看文檔。



1、說明

在某些操作的進度中的可視指示器,為用戶呈現操作的進度,還它有一個次要的進度條,用來顯示中間進度,如在流媒體播放的緩沖區的進度。一個進度條也可不確定其進度。在不確定模式下,進度條顯示循環動畫。這種模式常用於應用程序使用任務的長度是未知的。

2、XML重要屬性

android:progressBarStyle:默認進度條樣式

android:progressBarStyleHorizontal:水平樣式

3 重要方法

getMax():返回這個進度條的范圍的上限

getProgress():返回進度

getSecondaryProgress():返回次要進度

incrementProgressBy(int diff):指定增加的進度

isIndeterminate():指示進度條是否在不確定模式下

setIndeterminate(boolean indeterminate):設置不確定模式下

setVisibility(int v):設置該進度條是否可視

4 重要事件

onSizeChanged(int w, int h, int oldw, int oldh):當進度值改變時引發此事件

5進度條的樣式

Widget.ProgressBar.Horizontal長形進度

Androidxml 布局:

<ProgressBar

android:id="@+id/progress_bar"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

style="@android:style/Widget.ProgressBar.Horizontal "

/>

源碼:

private ProgressBar mProgress;

private int mProgressStatus=0;

private Handler mHandler=newHandler();

@Override

protected void onCreate(BundlesavedInstanceState){

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

mProgress=(ProgressBar)findViewById(R.id.progress_bar);

new Thread(new Runnable(){

@Override

public void run(){

while(mProgressStatus<100){

mProgressStatus=doWork();

mHandler.post(new Runnable(){

@Override

public void run(){

mProgress.setProgress(mProgressStatus);

}

});

}

}

}).start();

}

效果圖:

帶第二進度的進度條

xml配置如下:

<ProgressBar

android:id="@+id/progress_bar_with_second"

style="@android:style/Widget.ProgressBar.Horizontal"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:progress="40"

android:secondaryProgress="70"

android:paddingTop="20dp"

android:paddingBottom="20dp"/>

這里我們設置了初始的進度為40,android:progress的值在mini和max之間即mini<=progressvalue<=max

設置了第二進度條的進度值為70,該值也在mini和max之間。

效果如下:

不確定模式進度條

xml配置文件:

<ProgressBar

android:id="@+id/progress_bar_indeterminate"

style="@android:style/Widget.ProgressBar.Horizontal"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:indeterminate="true"

android:indeterminateBehavior="cycle"

android:paddingBottom="20dp"

android:paddingTop="20dp"

android:progress="40" />

這里通過android:indeterminate="true"設置了當前為無模式進度條

效果如圖:

普通圓形進度:Widget.ProgressBar.Inverse

<ProgressBar

android:id="@+id/progress_bar1"

style="@android:style/Widget.ProgressBar.Inverse"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:progress="50"

android:background="#ff00ff"

android:paddingTop="4dp" />

通過android:backgroup設置了背景色

熱點內容
php一鍵環境 發布:2025-08-25 20:20:34 瀏覽:161
無油螺桿式空氣壓縮機 發布:2025-08-25 20:16:06 瀏覽:815
python文件到輸出到文件 發布:2025-08-25 20:15:58 瀏覽:133
python列印日誌 發布:2025-08-25 19:37:00 瀏覽:413
vr哪個配置最好 發布:2025-08-25 19:36:51 瀏覽:836
解壓擠痘視頻 發布:2025-08-25 19:34:31 瀏覽:309
老鼠腳本是什麼意思 發布:2025-08-25 19:27:59 瀏覽:476
androidlongstring 發布:2025-08-25 19:25:00 瀏覽:495
app製作androidstudio 發布:2025-08-25 19:14:12 瀏覽:242
hibernate連接資料庫 發布:2025-08-25 18:55:37 瀏覽:720