當前位置:首頁 » 安卓系統 » android進度框

android進度框

發布時間: 2022-06-01 23:55:34

1. android 類似進度圓環的是怎麼做的

方法:

這是一個自定義Android組件,用於代替標准進度條組件。實現各種進度條樣式,包括圓環,掃描等。
XML:
在你的attr.xml(res/value)中加入以下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

<declare-styleable name="ProgressWheel">
<attr name="text"format="string"/>
<attr name="textColor"format="color"/>
<attr name="textSize"format="dimension"/>
<attr name="barColor"format="color"/>
<attr name="rimColor"format="color"/>
<attr name="rimWidth"format="dimension"/>
<attr name="spinSpeed"format="integer"/>
<attr name="circleColor"format="color"/>
<attr name="radius"format="dimension"/>
<attr name="barWidth"format="dimension"/>
<attr name="barLength"format="dimension"/>
<attr name="delayMillis"format="dimension"/>
<attr name="contourColor"format="color"/>
<attr name="contourSize"format="float"/>
</declare-styleable>

在你的root view 中加入

1

xmlns:ProgressWheel="http://schemas.android.com/apk/res/com.visualdenim.schooltraq"

1

在你的xml合適的地方加入 組件

1
2
3
4
5
6
7
8
9
10
11
12
13

<com.todddavies.components.progressbar.ProgressWheel
android:id="@+id/pw_spinner"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_centerInParent="true"
ProgressWheel:text="Authenticating..."
ProgressWheel:textColor="#222"
ProgressWheel:textSize="14sp"
ProgressWheel:rimColor="#330097D6"
ProgressWheel:barLength="60dp"
ProgressWheel:barColor="#0097D6"
ProgressWheel:barWidth="5dp"
ProgressWheel:rimWidth="2dp"/>

Java:
你需要從layout中獲得進度條,或者初始化

1
2

ProgressWheel pw = newProgressWheel(myContext, myAttributes);
ProgressWheel pw = (ProgressWheel) findViewById(R.id.pw_spinner);

使用.spin() 開始進度條滾動, .stopSpinning 停止進度條滾動
增加進度有點棘手, 你可以調用.incrementProgress(), 但是這樣就超過了360度, 因為一個圓有360度, 你超過360度就會自動重置, 一個百分百自動分配

2. android進度條怎麼顯示百分比

顯示百分比需要自己計算載入的內容,以下以webview示例,webview載入網頁的時候可以增加進度條:
1.從webview中獲取設置
websettings
sws
=
webview.getsettings();
sws.setsupportzoom(true);
sws.setbuiltinzoomcontrols(true);
webview.setinitialscale(25);
webview.getsettings().setusewideviewport(true);
2.注冊setwebchromeclient事件
webview.setwebchromeclient(new
webchromeclient()
{
public
void
onprogresschanged(webview
view,
int
progress)
{
//
activity和webview根據載入程度決定進度條的進度大小
//
當載入到100%的時候
進度條自動消失
//webviewprogressactivity.this.settitle("loading...");
//webviewprogressactivity.this.setprogress(progress
*
100);
if
(progress
==
100)
{
progressbar.setvisibility(view.gone);
//webviewprogressactivity.this.settitle("完成");
}
}
});
3.注意在onprogresschanged中處理進度,progress就是進度值。

3. android 繪制進度條

進度條一般是用來顯示耗時操作的,如你圖示,最終完成的時候剛好繞一圈,是一個計時器來確定進度條跑完一圈的時間,然後按時間的流逝來繪制進度條(也就是邊框)。
我的思路是這樣的,首先確定進度條的起始位置,也就是黑色背景圖的上部中間(前提是獲取到背景圖片四個角角位置坐標(X,Y)),計算出圖片的長寬,這樣背景圖片四個角的坐標都有了,進度條的起始坐標也有了,然後根據周長和定時器的時間確定我們每毫秒需要繪制多長,遇到拐角的時候判斷一下進度條的實時坐標與背景圖的拐角坐標是否一致,然後就拐個彎,繼續繪制。
這是個思路,我過會兒調試一下

4. android怎麼使用自定義進度條對話框中的控制項

在需要引用自定義進度條的xml的ProgressBar中添加android:indeterminateDrawable="@drawable/自定義進度條xml文件名稱"

5. 安卓怎麼在在對話框中 搞一個進度條

方法/步驟:
單擊按鈕,彈出對話框,對話框中有進度條!
下面 來實現這個功能了

新建一個android工程,定義好xml 只需要一個button就可以了
在MainAtvity中,定義
ProgressDialog m_pDialog;

創建單擊響應事件
在OncliView中可以
m_pDialog = new ProgressDialog(MainActivity.this);

// 設置進度條風格,風格為圓形,旋轉的

m_pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);

// 設置ProgressDialog 標題

m_pDialog.setTitle("提示");

// 設置ProgressDialog 提示信息

m_pDialog.setMessage("這是一個圓形進度條對話框");

// 設置ProgressDialog 標題圖標

// 設置ProgressDialog 的進度條是否不明確

m_pDialog.setIndeterminate(false);

// 設置ProgressDialog 是否可以按退回按鍵取消

m_pDialog.setCancelable(true);
m_pDialog.show();
4
完成,單擊按鈕 就可以彈出對話框,(包含進度條~~)

6. android 怎麼自定義繪制如下圖中這種進度條

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

要想看各種進度條的實現代碼和文檔,直接去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設置了背景色

7. android開發中videoview的自帶的進度條如何隱藏

android自帶的播放器的進度條是默認會自動隱藏的,不能設置的。除非你去改源代碼。你可以下個其他的播放器,看看能不能設置為不自動隱藏。

8. android 進度條樣式 怎麼改

Android系統提供了兩大類進度條樣式,長形進度條(progressBarStyleHorizontal) 和圓形進度條(progressBarStyleLarge)。

android 進度條樣式更改:

  • 第一種

    (默認樣式(中等圓形))

進度條用處很多,比如,應用程序裝載資源和網路連接時,可以提示用戶稍等,這一類進度條只是代表應用程序中某一部分的執行情況,而整個應用程序執行情況呢,則可以通過應用程序標題欄來顯示一個進度條,這就需要先對窗口的顯示風格進行設置"requestWindowFeature(Window.FEATURE_PROGRESS)"。

熱點內容
安卓手機里照片如何快速轉移 發布:2025-08-20 10:03:24 瀏覽:191
jakarta文件上傳 發布:2025-08-20 09:24:20 瀏覽:779
javafor循環嵌套if 發布:2025-08-18 23:28:21 瀏覽:306
西裝配領演算法 發布:2025-08-18 23:26:38 瀏覽:507
ecshopsql漏洞 發布:2025-08-18 23:17:01 瀏覽:804
mac臨時文件夾 發布:2025-08-18 23:14:55 瀏覽:772
阿里雲搭建傳奇伺服器 發布:2025-08-18 23:14:06 瀏覽:460
硬體加密卡 發布:2025-08-18 23:08:17 瀏覽:992
農信交易密碼指的是什麼密碼 發布:2025-08-18 23:03:20 瀏覽:589
數組存儲空間 發布:2025-08-18 23:01:50 瀏覽:759