當前位置:編程學習大全網 - 腳本源碼 - delphi xe android 更改ProgressBar1進度條顏色

delphi xe android 更改ProgressBar1進度條顏色

下面是安卓學習手冊中實現各種進度條的截圖:

要想看各種進度條的實現代碼和文檔,直接去360手機助手中下載安卓學習手冊,例子文檔隨便看。

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設置了背景色

  • 上一篇:劍魔的加點方式
  • 下一篇:dnf戰鬥法師武器
  • copyright 2024編程學習大全網