❶ android界面设计,下面图的那个圆形进度条怎么设计
这个你要自定义 Android 进度条。
自定义 progressbar 的样式。
❷ 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
通过MediaPlayer调节。
系统自带的进度条的颜色比较单调,实际开发中使用较少,可以自定义进度条背景,新建一个progressbarbg.xml文件。gradient可以设置进度条的渐变色,android:endColor和android:startColor可以设置渐变开始和结束的颜色。定义完成以后,便可以使用。
在音乐进度,网络下载时,需动态加载进度条,默认情况下,设置进度条,使用setProgress即可。但有时除了动态设置进度,仍需要动态设置进度条颜色通过MediaPlayer播放音乐并获取进度,设置进度。
❹ AndroidStudio编程,如何把圆形ProgressBar的中心位置和FloatingActionButton的中心位置进行绑定
FloatingActionButton(简称FAB)的使用方法非常的简单
和一个普通控件一样,在xml布局文件中定义(记得导入Design包)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
src:设置FAB的图标,google建议图标的大小为24dp
backgroundTint:按钮的默认颜色
borderWidth:设置为0dp,不然在4.1的SDK上会显示方块形,在5.x的系统上运行会没有阴影
pressedTranslationZ:设置立体感,点击时的阴影大小,默认是12dp
fabSize:设置FloatingActionButton的大小样式,normal为正常大小(56dp),mini为小号的(40dp)
elevation:设置立体感,正常情况下阴影的大小,默认为6dp
rippleColor:点击时的颜色,默认取theme中colorControlHighlight的颜色
FAB的点击事件和普通View的点击事件一样,使用OnClickListener设置监听
原生的FAB在体验上并不友好,因为它遮挡住了要显示的内容,尤其是在和ListView等控件搭配时,如果页面滚动到了最后,那么遮住的部位就显示不出来了。
解决方法:在页面向下滑动的时候隐藏FAB,向上滑动时再显示出来
❺ 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开发怎么自定义绘制如下图中这种进度条急需!在线等!
一)变换前背景
先来看看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.....
❼ 求教 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自定义环形进度条怎么自由控制进度条的消失与隐藏
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 如何在一个fragment里放置一个圆形进度条
一样的啊 都一样用啊
❿ 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信息,进而方便我们测试。以下是测试信息。简单明了。
步骤阅读