當前位置:首頁 » 安卓系統 » android圓形的進度條

android圓形的進度條

發布時間: 2022-05-18 22:34:00

① android progressbar 為什麼是圓的

繼承於View類,直接子類有AbsSeekBar和ContentLoadingProgressBar,其中AbsSeekBar的子類有SeekBar和RatingBar,可見這二者也是基於ProgressBar實現的。

1、ProgressBar有兩個進度,一個是android:progress,另一個是android:secondaryProgress。後者主要是為緩存需要所涉及的,比如在看網路視頻時候都會有一個緩存的進度條以及還要一個播放的進度,在這里緩存的進度就可以是android:secondaryProgress,而播放進度就是android:progress,有了secondProgress,可以很方便定製ProgressBar。

2、ProgressBar分為確定的和不確定的,確定的是我們能明確看到進度,相反不確定的就是不清楚、不確定一個操作需要多長時間來完成,這個時候就需要用的不確定的ProgressBar了。屬性android:indeterminate如果設置為true的話,那麼ProgressBar就可能是圓形的滾動條或者水平的滾動條(由樣式決定),但是我們一般時候,是直接使用Style類型來區分圓形還是水平ProgressBar的。
3、ProgressBar的樣式設定其實有兩種方式,在API文檔中說明的方式如下:

Widget.ProgressBar.Horizontal
Widget.ProgressBar.Small
Widget.ProgressBar.Large
Widget.ProgressBar.Inverse
Widget.ProgressBar.Small.Inverse
Widget.ProgressBar.Large.Inverse
使用的時候可以這樣:style="@android:style/Widget.ProgressBar.Small",另外還有一種方式就是使用系統的attr,下面的方式是系統的style:

style="?android:attr/progressBarStyle"
style="?android:attr/progressBarStyleHorizontal"
style="?android:attr/progressBarStyleInverse"
style="?android:attr/progressBarStyleLarge"
style="?android:attr/progressBarStyleLargeInverse"
style="?android:attr/progressBarStyleSmall"
style="?android:attr/progressBarStyleSmallInverse"
style="?android:attr/progressBarStyleSmallTitle"
[java] view plain
<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleHorizontal"
style="@android:style/Widget.ProgressBar.Horizontal"(等同於@android:attr)
android:layout_width="match_parent"
android:layout_height="wrap_content" />

② Android 如何在一個fragment里放置一個圓形進度條

一樣的啊 都一樣用啊

③ android中怎麼讓圓形進度條動畫

首先解決問題一的問題: 你肯定使用了系統的 oncreateDialog 和 showdialog 方法了,所以 這個就會顯示一次 第二次不顯示了 , 你應該調用 dialog方法裡面的 show()方法 來顯示,這樣每次顯示那個progressbar都會在轉圈 問題二: 你說下面設置了一個白色背景,但是下面還是有個框,不過我有個疑問,如果你設置為白色背景,那麼你的轉條默認是白色的不就看不見了嗎?好了這個問題不糾結了!那個黑色的是邊框導致的,去掉邊框就行了 一般我們採用的是自定義dialog,也就是寫一個類來繼承dialog,這個時候的構造函數是這個: public MyDialog(Context context, int theme) { super(context, theme); this.context = context; init(); } 這個theme是什麼東西呢? 就是一個style樣式 如下: <resources>    <style name="dialog" parent="@android:style/Theme.Dialog">        <item name="android:windowFrame">@null</item><!--邊框--        <item name="android:windowIsFloating">true</item><!--是否浮現在activity之上--       <item name="android:windowIsTranslucent">false</item><!--半透明--        <item name="android:windowNoTitle">true</item><!--無標題--        <item name="android:windowBackground">@color/transparent</item><!--背景透明--        <item name="android:backgroundDimEnabled">false</item><!--模糊--    </style></resources>  其他代碼: @Override public boolean onKeyDown(int keyCode, KeyEvent event) { Dialog dialog = new MyDialog(this, R.style.MyDialog); android.view.WindowManager.LayoutParams pa3 = new android.view.WindowManager.LayoutParams(); pa3.height = android.view.WindowManager.LayoutParams.WRAP_CONTENT; pa3.width = android.view.WindowManager.LayoutParams.WRAP_CONTENT; pa3.x = 0;//x 起點 pa3.y = 0;//y起點 Window window = dialog.getWindow(); window.setAttributes(pa3); dialog.show(); return super.onKeyDown(keyCode, event); } 之所以android.view.WindowManager.LayoutParams我要這么寫,因為LayoutParams太多了,我害怕你找半天,兄弟對你夠好了吧! 要是選為精彩回答 那就謝謝你了!

④ android有沒有圓形第三方框架顯示圓形進度條倒計時

使用IDV ,外層DIV畫進度條矩形邊框,內層DIV使用JS,進行填充寬度

⑤ Android開發中,關於對話框中的圓形進度條和Layout的問題

首先解決問題一的問題:
你肯定使用了系統的 oncreateDialog 和 showdialog 方法了,所以 這個就會顯示一次 第二次不顯示了 , 你應該調用 dialog方法裡面的 show()方法 來顯示,這樣每次顯示那個progressbar都會在轉圈

問題二:
你說下面設置了一個白色背景,但是下面還是有個框,不過我有個疑問,如果你設置為白色背景,那麼你的轉條默認是白色的不就看不見了嗎?好了這個問題不糾結了!那個黑色的是邊框導致的,去掉邊框就行了

一般我們採用的是自定義dialog,也就是寫一個類來繼承dialog,這個時候的構造函數是這個:

public MyDialog(Context context, int theme) {
super(context, theme);
this.context = context;
init();
}

這個theme是什麼東西呢? 就是一個style樣式 如下:

<resources>    <style name="dialog" parent="@android:style/Theme.Dialog">        <item name="android:windowFrame">@null</item><!--邊框--        <item name="android:windowIsFloating">true</item><!--是否浮現在activity之上--      
<item name="android:windowIsTranslucent">false</item><!--半透明--        <item name="android:windowNoTitle">true</item><!--無標題--        <item name="android:windowBackground">@color/transparent</item><!--背景透明--        <item name="android:backgroundDimEnabled">false</item><!--模糊--    </style></resources> 

其他代碼:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
Dialog dialog = new MyDialog(this, R.style.MyDialog);

android.view.WindowManager.LayoutParams pa3 = new android.view.WindowManager.LayoutParams();
pa3.height = android.view.WindowManager.LayoutParams.WRAP_CONTENT;
pa3.width = android.view.WindowManager.LayoutParams.WRAP_CONTENT;
pa3.x = 0;//x 起點
pa3.y = 0;//y起點
Window window = dialog.getWindow();
window.setAttributes(pa3);
dialog.show();
return super.onKeyDown(keyCode, event);
}
之所以android.view.WindowManager.LayoutParams我要這么寫,因為LayoutParams太多了,我害怕你找半天,兄弟對你夠好了吧!
要是選為精彩回答 那就謝謝你了!

⑥ android 圓形進度條 卡住

不太明白你的意思 你是說你在下載的時候顯示圓形進度條完成後顯示文本嗎 那就應該 把進度條去掉或者提示完成之後在顯示 文本啊 卡主了可能由於你沒有去掉進度條吧 希望對你有幫助

⑦ 求教 android半圓弧形的進度條問題

package com.example.roundprogressbar;import android.content.Context;import android.content.res.TypedArray;import android.graphics.Canvas;import android.graphics.Color;import android.graphics.Paint;import android.graphics.RectF;import android.graphics.Typeface;import android.util.AttributeSet;import android.util.Log;import android.view.View;import com.example.circlepregress.R;/** * 仿iphone帶進度的進度條,線程安全的View,可直接在線程中更新進度 * @author xiaanming * */public class RoundProgressBar extends View {/*** 畫筆對象的引用*/private Paint paint;/*** 圓環的顏色*/private int roundColor;/*** 圓環進度的顏色*/private int roundProgressColor;/*** 中間進度百分比的字元串的顏色*/private int textColor;/*** 中間進度百分比的字元串的字體*/private float textSize;/*** 圓環的寬度*/private float roundWidth;/*** 最大進度*/private int max;/*** 當前進度*/private int progress;/*** 是否顯示中間的進度*/private boolean textIsDisplayable;/*** 進度的風格,實心或者空心*/private int style;public static final int STROKE = 0;public static final int FILL = 1;public RoundProgressBar(Context context) {this(context, null);}public RoundProgressBar(Context context, AttributeSet attrs) {this(context, attrs, 0);}public RoundProgressBar(Context context, AttributeSet attrs, int defStyle) {super(context, attrs, defStyle);paint = new Paint();TypedArray mTypedArray = context.obtainStyledAttributes(attrs,R.styleable.RoundProgressBar);//獲取自定義屬性和默認值roundColor = mTypedArray.getColor(R.styleable.RoundProgressBar_roundColor, Color.RED);roundProgressColor = mTypedArray.getColor(R.styleable.RoundProgressBar_roundProgressColor, Color.GREEN);textColor = mTypedArray.getColor(R.styleable.RoundProgressBar_textColor, Color.GREEN);textSize = mTypedArray.getDimension(R.styleable.RoundProgressBar_textSize, 15);roundWidth = mTypedArray.getDimension(R.styleable.RoundProgressBar_roundWidth, 5);max = mTypedArray.getInteger(R.styleable.RoundProgressBar_max, 100);textIsDisplayable = mTypedArray.getBoolean(R.styleable.RoundProgressBar_textIsDisplayable, true);style = mTypedArray.getInt(R.styleable.RoundProgressBar_style, 0);mTypedArray.recycle();}@Overrideprotected void onDraw(Canvas canvas) {super.onDraw(canvas);/*** 畫最外層的大圓環*/int centre = getWidth()/2; //獲取圓心的x坐標int radius = (int) (centre - roundWidth/2); //圓環的半徑paint.setColor(roundColor); //設置圓環的顏色paint.setStyle(Paint.Style.STROKE); //設置空心paint.setStrokeWidth(roundWidth); //設置圓環的寬度paint.setAntiAlias(true); //消除鋸齒 canvas.drawCircle(centre, centre, radius, paint); //畫出圓環Log.e("log", centre + "");/*** 畫進度百分比*/paint.setStrokeWidth(0); paint.setColor(textColor);paint.setTextSize(textSize);paint.setTypeface(Typeface.DEFAULT_BOLD); //設置字體int percent = (int)(((float)progress / (float)max) * 100); //中間的進度百分比,先轉換成float在進行除法運算,不然都為0float textWidth = paint.measureText(percent + "%"); //測量字體寬度,我們需要根據字體的寬度設置在圓環中間if(textIsDisplayable && percent != 0 && style == STROKE){canvas.drawText(percent + "%", centre - textWidth / 2, centre + textSize/2, paint); //畫出進度百分比}/*** 畫圓弧 ,畫圓環的進度*///設置進度是實心還是空心paint.setStrokeWidth(roundWidth); //設置圓環的寬度paint.setColor(roundProgressColor); //設置進度的顏色RectF oval = new RectF(centre - radius, centre - radius, centre+ radius, centre + radius); //用於定義的圓弧的形狀和大小的界限switch (style) {case STROKE:{paint.setStyle(Paint.Style.STROKE);canvas.drawArc(oval, 0, 360 * progress / max, false, paint); //根據進度畫圓弧break;}case FILL:{paint.setStyle(Paint.Style.FILL_AND_STROKE);if(progress !=0)canvas.drawArc(oval, 0, 360 * progress / max, true, paint); //根據進度畫圓弧break;}}}public synchronized int getMax() {return max;}/*** 設置進度的最大值* @param max*/public synchronized void setMax(int max) {if(max max){progress = max;}if(progress <= max){this.progress = progress;postInvalidate();}}public int getCricleColor() {return roundColor;}public void setCricleColor(int cricleColor) {this.roundColor = cricleColor;}public int getCricleProgressColor() {return roundProgressColor;}public void setCricleProgressColor(int cricleProgressColor) {this.roundProgressColor = cricleProgressColor;}public int getTextColor() {return textColor;}public void setTextColor(int textColor) {this.textColor = textColor;}public float getTextSize() {return textSize;}public void setTextSize(float textSize) {this.textSize = textSize;}public float getRoundWidth() {return roundWidth;}public void setRoundWidth(float roundWidth) {this.roundWidth = roundWidth;}}package com.example.roundprogressbar;import android.app.Activity;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;import com.example.circlepregress.R;public class MainActivity extends Activity {private RoundProgressBar mRoundProgressBar1, mRoundProgressBar2 ,mRoundProgressBar3, mRoundProgressBar4, mRoundProgressBar5;private int progress = 0;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_cricle_progress);mRoundProgressBar1 = (RoundProgressBar) findViewById(R.id.roundProgressBar1);mRoundProgressBar2 = (RoundProgressBar) findViewById(R.id.roundProgressBar2);mRoundProgressBar3 = (RoundProgressBar) findViewById(R.id.roundProgressBar3);mRoundProgressBar4 = (RoundProgressBar) findViewById(R.id.roundProgressBar4);mRoundProgressBar5 = (RoundProgressBar) findViewById(R.id.roundProgressBar5);((Button)findViewById(R.id.button1)).setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {new Thread(new Runnable() {@Overridepublic void run() {while(progress <= 100){progress += 3;System.out.println(progress);mRoundProgressBar1.setProgress(progress);mRoundProgressBar2.setProgress(progress);mRoundProgressBar3.setProgress(progress);mRoundProgressBar4.setProgress(progress);mRoundProgressBar5.setProgress(progress);try {Thread.sleep(100);} catch (InterruptedException e) {e.printStackTrace();}}}}).start();}});}}activity_cricle_progress.xml剛好做過,通過復寫oncanvas實現的求教 android半圓弧形的進度條問題

⑧ Android界面設計,下面圖的那個圓形進度條怎麼設計

這個你要自定義 Android 進度條。
自定義 progressbar 的樣式。

⑨ android內部帶刻度的圓形進度條

78910111213
//circleCenter 整個圓半徑 radius圓環的半徑
RectF oval = new RectF(circleCenter - radius, circleCenter - radius, circleCenter + radius, circleCenter + radius);
//因為-90°才是從12點鍾方向開始 所以從-90開始 progress 為進度
canvas.drawArc(oval, -90, (float) (progress * 3.6), false, paint);

熱點內容
android換背景 發布:2025-08-18 13:16:47 瀏覽:16
易語言gdi源碼 發布:2025-08-18 13:06:05 瀏覽:782
iphone5s軟體緩存 發布:2025-08-18 12:39:37 瀏覽:148
QQ推薦上傳 發布:2025-08-18 12:38:51 瀏覽:860
qq忘記密保怎麼找回密碼 發布:2025-08-18 12:38:18 瀏覽:72
python字元串類型轉換 發布:2025-08-18 12:35:54 瀏覽:399
ofdm信道估計演算法 發布:2025-08-18 12:35:09 瀏覽:733
指數競猜源碼 發布:2025-08-18 12:29:26 瀏覽:698
天龍八部莫愁腳本官網 發布:2025-08-18 12:14:19 瀏覽:862
合資車為什麼配置不高 發布:2025-08-18 12:09:36 瀏覽:76