当前位置:首页 » 安卓系统 » 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);

热点内容
云服务器在哪里开端口 发布:2025-08-20 16:09:47 浏览:494
域控制服务器dns和ip 发布:2025-08-20 16:05:21 浏览:539
怎样让隐藏文件夹显示 发布:2025-08-20 16:03:37 浏览:36
如何辨别密码箱密码锁坏了 发布:2025-08-20 16:02:47 浏览:970
河池都安服务器ip地址是什么 发布:2025-08-20 16:00:13 浏览:874
做自媒体剪辑需要什么配置的电脑 发布:2025-08-20 15:37:38 浏览:388
密码法的立法目地是什么 发布:2025-08-20 15:27:13 浏览:456
不小心删除微信怎么恢复聊天记录安卓 发布:2025-08-20 15:27:05 浏览:449
车载安卓系统指的是什么 发布:2025-08-20 15:23:47 浏览:713
安徽鲲鹏服务器云空间 发布:2025-08-20 15:19:37 浏览:790