导航:首页 > 操作系统 > android圆环进度条

android圆环进度条

发布时间:2022-12-18 13:55:41

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 自定义加载圆环控件里面怎么设置三行字

public
class
MyView
extends
View{
//此处省略构造方法
private
void
onDraw(Canvas
canvas){
//重写view的onDraw方法,绘制控件的样式
//这里你使用canvas来绘制,你布局中使用这个控件就是你绘制的样子
}
//然后你可以定义很多自己的一些方法,用来修改控件的样式
//假如你自定义的一个进度条的话,就要修改进度条值,你就可以自定义方法,让实现对象来改变进度值,记得修改后调用validate方法更新显示。(具体函数记不太清了)
}
大概就是这样实现的自定义控件,自定义控件的话优化是很重要的哦,不然性能会很差。
然后你要使用这个控件的话,在布局中就需要这样定义,假如这个自定义控件类是这样的:
xxx.xxx.MyView。
则使用时:
<xxx.xxx.MyView
这些地方一样的设置宽高,id啊杂七杂八的属性
/>

④ 求教 android半圆弧形的进度条问题

package com.example.comt;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.RectF;
import android.graphics.Shader;
import android.util.AttributeSet;
import android.view.View;

public class CircleView extends View {

Paint paint,textpaint;
RectF area;
int value = 100;
LinearGradient shader;

public CircleView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
// TODO Auto-generated constructor stub
}

public CircleView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
// TODO Auto-generated constructor stub
}

public CircleView(Context context) {
super(context);
init();
// TODO Auto-generated constructor stub
}

public void setProgress(int value){
this.value = value;
invalidate();
}

public void init() {
paint = new Paint();
paint.setStrokeWidth(50f);
paint.setColor(Color.WHITE);
paint.setStyle(Style.STROKE);
paint.setAntiAlias(true);
textpaint = new Paint();
textpaint.setTextSize(50f);
textpaint.setColor(Color.WHITE);
area = new RectF(100, 100, 500, 500);

shader =new LinearGradient(0, 0, 400, 0, new int[] {
Color.BLUE, Color.WHITE}, null,
Shader.TileMode.CLAMP);
paint.setShader(shader);

}

@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
canvas.drawColor(Color.GRAY);
canvas.drawArc(area, 120, 360*value/100 , false, paint);
canvas.drawText(value+"%", 270, 290, textpaint);
}

}

看下是不是你想要的,调用setprogress()既可调节圆环

⑤ android自定义环形进度条怎么自由控制进度条的消失与隐藏

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bluetoothmeter);
mhandler = new Handler();

//通过mSearcheHandler更新UI
mSearchHandler=new Handler(){
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if(msg.what==0){
//改变环形进度条的进度
mCircleProcessBar.setProgress(mcnt);
mcnt+=1;
if(MCNT_MAX<=mcnt){
mCircleProcessBar.setVisibility(View.GONE);
}
}
}
};
mBlueService = BluetoothLeService.getInstance();
initView();
initEvent();
}

private void initEvent()
{
mImgBtnBack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
//搜索
mbtnSearch.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// Prepare list view and initiate scanning
if (m_devicelistadapter != null) {
m_devicelistadapter.clear();
m_devicelistadapter.notifyDataSetChanged();

}
startScan();

//设置圆环进度条的出现时间(秒)
new TimerDelay(mSearchHandler).setDelayTime(CIRCLE_APPARE_TIME,mCircleProcessBar);
mcnt=1;
}
});
}

⑥ android 圆形progressbar系统样式有时候进度条没有

Android中ProgressBar自定义进度条的高度、颜色、圆角
很多人知道怎么改颜色,可是改高度就是胡扯了,居然想通过maxHeight去改。准确方法在这里:

下面这个改成了3-5个dp高度:

首先是样式文件,这里定义高度:

⑦ Android开发怎么自定义绘制如下图中这种进度条急需!在线等!

一)变换前背景

先来看看progressbar的属性:
1. <ProgressBar
2. android:id="@+id/progressBar"
3. style="?android:attr/progressBarStyleHorizontal"
4. android:layout_width="match_parent"
5. android:layout_height="wrap_content"
6. android:layout_margin="5dip"
7. android:layout_toRightOf="@+id/progressBarV"
8. android:indeterminate="false"
9. android:padding="2dip"
10. android:progress="50" />
根据style="?android:attr/progressBarStyleHorizontal",我们找到源码中的style.xml
1. <style name="Widget.ProgressBar.Horizontal">
2. <item name="android:indeterminateOnly">false</item>
3. <item name="android:progressDrawable">@android:drawable/progress_horizontal</item>
4. <item name="android:indeterminateDrawable">@android:drawable/progress_indeterminate_horizontal</item>
5. <item name="android:minHeight">20dip</item>
6. <item name="android:maxHeight">20dip</item>
7. </style>
看到
<item name="android:progressDrawable">@android:drawable/progress_horizontal</item>
木有,继续发掘源码,找到drawable下面的progress_horizontal.xml,这就是我们今天的主角了:
1. <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
2.
3. <item android:id="@android:id/background">
4. <shape>
5. <corners android:radius="5dip" />
6. <gradient
7. android:startColor="#ff9d9e9d"
8. android:centerColor="#ff5a5d5a"
9. android:centerY="0.75"
10. android:endColor="#ff747674"
11. android:angle="270"
12. />
13. </shape>
14. </item>
15.
16. <item android:id="@android:id/secondaryProgress">
17. <clip>
18. <shape>
19. <corners android:radius="5dip" />
20. <gradient
21. android:startColor="#80ffd300"
22. android:centerColor="#80ffb600"
23. android:centerY="0.75"
24. android:endColor="#a0ffcb00"
25. android:angle="270"
26. />
27. </shape>
28. </clip>
29. </item>
30.
31. <item android:id="@android:id/progress">
32. <clip>
33. <shape>
34. <corners android:radius="5dip" />
35. <gradient
36. android:startColor="#ffffd300"
37. android:centerColor="#ffffb600"
38. android:centerY="0.75"
39. android:endColor="#ffffcb00"
40. android:angle="270"
41. />
42. </shape>
43. </clip>
44. </item>
45.
46. </layer-list>
看到android:id="@android:id/progress"木有,看到android:id="@android:id/secondaryProgress"木有
把这个文件复制到自己工程下的drawable,就可以随心所欲的修改shape的属性,渐变,圆角等等
那么怎么放一个图片进去呢,ok,新建progress_horizontal1.xml:
1. <?xml version="1.0" encoding="utf-8"?>
2. <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
3.
4. <item android:id="@android:id/progress" android:drawable="@drawable/progressbar" />
5.
6. </layer-list>
在android:drawable中指定你处理好的图片
然后回到布局中
1. <ProgressBar
2. android:id="@+id/progressBar1"
3. android:layout_width="match_parent"
4. android:layout_height="wrap_content"
5. android:layout_below="@+id/progressBar"
6. android:layout_margin="5dip"
7. android:layout_toRightOf="@+id/progressBarV"
8. android:background="@drawable/progress_bg"
9. android:indeterminate="false"
10. android:indeterminateOnly="false"
11. android:maxHeight="20dip"
12. android:minHeight="20dip"
13. android:padding="2dip"
14. android:progress="50"
15. android:progressDrawable="@drawable/progress_horizontal1" />
android:background="@drawable/progress_bg"指定背景
android:progressDrawable="@drawable/progress_horizontal1"前景使用上面的progress_horizontal1

要是还不行

你来我们群里说吧

这里是开发者互相学习交流的 有大神

让他们给你解释你的疑问 号 码look at my n a m e.....

⑧ 如何在自定义view中实现这样的渐变圆环进度条

在 PHOTOSHOP CS5 中创建一个自定义渐变颜色的方法是:1、新建白色背景文件,打开“渐变工具”;2、设置渐变颜色,新建,存储;3、打开“渐变工具”选择自定义渐变,拉渐变,完成。

⑨ android进度条上的小球怎么设置

谓进度条、滑动条和评分控件,在手机应用中,相信你见过加载游戏时、更新应用时等情况,屏幕出现一条进度栏,这里称之为进度条;当你调节音量时出现的这里即称作滑动条;而评分控件,当你在淘宝给卖家评价时出现的类似5星评价,这里即称作评分控件,下面将分别详细说明这三种控件的基础使用方法。
工具/原料

eclipse
一、ProgressBar进度条控件

1
首先ProgressBar进度条给出了两种样式,分别是progressBarStyleLarge和progressBarStyleHorizontal,此次主要以progressBarStyleHorizontal水平进度条为例讲解,可在视图布局Form Widgets中找到,其布局代码和布局演示示例如下。

2
ProgressBar进度条需要创建一个继承AsyncTask抽象类的Activity,并重写doInBackground和onProgressUpdate方法,来实现进度条的基础功能,在此之前确保已经创建了Acticity并获取了ProgressBar控件。其代码如下:

3
增加按钮创建点击事件使进度条可以实现功能,并设置最大数值100。其代码如下。

END
二、SeekBar滑动条控件

1
首先将SeekBar滑动条的View写出来,具体代码和样式如下。

2
然后调用SeekBar控件,并设置总进度大小和设置监听事件,以便对滑动条后续操作。和ProgressBar进度条一样,用到了setMax方法来确定大小。另外还用到了setOnSeekBarChangeListener进行监听滑动条的事件状态。相关代码如下:

END
三、RatingBar评分控件

RatingBar评分控件和SeekBar滑动条控件类似,首先还是先来把View视图写好,但要注意其中有一个属性,android:numStars="6",表示总分是6分,代码和样式如下:

然后同样再在Activity中调用RatingBar控件,并使用setOnRatingBarChangeListener方法来测试监听评分的状态。相关代码如下:

最后针对如System.out.println("-->"+rating);这个形式,这个测试方法,可以过滤的多余的无用LogCat信息,进而方便我们测试。以下是测试信息。简单明了。
步骤阅读

⑩ 求教 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圆环进度条相关的资料

热点内容
异性下载什么app 浏览:678
51单片机程序单步视频 浏览:239
家庭宽带如何连接服务器 浏览:117
汽车高压泵解压 浏览:770
上门正骨用什么app 浏览:758
安卓为什么免费使用 浏览:397
加密货币都有哪些平台 浏览:625
python和matlab难度 浏览:388
python爬虫很难学么 浏览:572
小米解压积木可以组成什么呢 浏览:816
为什么滴滴出行app还能用 浏览:564
怎么升级手机android 浏览:923
php权威编程pdf 浏览:994
扣扣加密技巧 浏览:721
苹果如何创建服务器错误 浏览:497
软考初级程序员大题分值 浏览:475
js压缩视频文件 浏览:580
linux如何通过命令创建文件 浏览:991
应用加密app还能访问应用嘛 浏览:435
安卓怎么用支付宝交违章罚款 浏览:667