① 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半圓弧形的進度條問題