各种进度条效果
来源:互联网 发布:易语言lua源码 编辑:程序博客网 时间:2024/06/05 17:23
代码:
Main.java
Progress.javapackage com.android.chen.main;
import com.android.chen.util.IntentUtils;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
/**
* <一句话功能简述>首页面,包含三个按钮<BR>
* <功能详细描述>
*
* @author chenli
* @version [版本号, 2011-4-8]
* @see [相关类/方法]
* @since [产品/模块版本]
*/
public class Main extends Activity
{
/**
* 显示圆形进度条的dialog
*/
private Dialog mDialog;
/**
* 列表 各种进度条的样式名称
*/
private ListView mListView;
@Override
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
initProperty();
}
/**
* <一句话功能简述>初始化页面组件及事件<br>
* <功能详细描述>
*
* @see [类、类#方法、类#成员]
*/
private void initProperty()
{
/**
*
* 列表中展示的文字内容
*/
String[] texts = {
getResources().getString(R.string.yinlian),
getResources().getString(R.string.color),
getResources().getString(R.string.left),
getResources().getString(R.string.right),
getResources().getString(R.string.indeter),
getResources().getString(R.string.vertical_pic),
getResources().getString(R.string.round_anim),
getResources().getString(R.string.round_color),
getResources().getString(R.string.round_pic)
};
mListView = (ListView) findViewById(R.id.listview);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.item,R.id.type,texts);
mListView.setAdapter(adapter);
mListView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
Toast.makeText(Main.this, "position = " + arg2, 0).show();
switch (arg2)
{
case 0:
/**
* 通过动画达到效果
*/
// showIntent(SelfDefProgressActivity.class);
/**
* 每次移动光标达到效果
*/
showIntent(ProgressActivity.class);
/**
* 通过自定义view实现
*/
showIntent(ProgressDemoActivity.class);
break;
case 1:
showIntent(ProgressBar_Color.class);
break;
case 2:
showIntent(ProgressBar_Left.class);
break;
case 3:
showIntent(ProgressBar_Right.class);
break;
case 4:
showIntent(ProgressBar_Indeter.class);
break;
case 5:
showIntent(VerticalPic.class);
break;
case 6:
showRoundProcessDialog(Main.this, R.layout.loading_process_dialog_anim);
break;
case 7:
showRoundProcessDialog(Main.this, R.layout.loading_process_dialog_color);
break;
case 8:
showRoundProcessDialog(Main.this, R.layout.loading_process_dialog_icon);
break;
default:
break;
}
}
});
}
/**
* <一句话功能简述>Intent页面跳转<br>
* <功能详细描述>
*
* @param mclass
* @see [类、类#方法、类#成员]
*/
private void showIntent(Class<?> mclass)
{
IntentUtils.getInstance().intentForward(this, mclass);
}
/**
* <一句话功能简述> 显示圆形进度条 <br>
* @param mContext
* @param layout
*/
public void showRoundProcessDialog(Context mContext, int layout){
mDialog = new AlertDialog.Builder(mContext).create();
mDialog.show();
// 注意此处要放在show之后 否则会报异常
mDialog.setContentView(layout);
mDialog.setCancelable(true); //false设置点击其他地方不能取消进度条
}
}
ProgressActivity.java/**
*@project name: ProgressDemo
*@file name: Progress.java
*@date 2012-1-17 上午11:42:07
*@author kester.zhang
*@Copyright (C) 2011 NanJing BBMF Information Technology Co., Ltd.(Shanghai Branch)
*/
package com.android.chen.main;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
/**
* @author
* */
public class Progress extends SurfaceView implements SurfaceHolder.Callback,Runnable{
/**
* 画笔对象
* */
private Paint paint;
/**
* canvas对象
* */
private Canvas canvas;
/**
* surfaceholder对象
* */
private SurfaceHolder holder;
/**
* 标志位
* */
private boolean flag = false;
/**
* 黑色线
* */
private Bitmap blackline;
/**
* 白色线
* */
private Bitmap whiteline;
/**
* 背景
* */
private Bitmap background;
/**
* 亮点
* */
private Bitmap light;
/**
* 刷新频率
* */
private long delay = 100;
/**
* 热点的长度
* */
private int clipx;
/**
* 进度条移动步长
* */
private static final int foot = 10;
private onFinishLinstener ofl;
public Progress(Context context) {
super(context);
init();
}
private void init(){
holder = this.getHolder();
holder.addCallback(this);
paint = new Paint();
paint.setDither(true);
background = BitmapFactory.decodeResource(getResources(), R.drawable.bg);
blackline = BitmapFactory.decodeResource(getResources(), R.drawable.a1);
whiteline = BitmapFactory.decodeResource(getResources(), R.drawable.a2);
light = BitmapFactory.decodeResource(getResources(), R.drawable.c);
}
public void surfaceCreated(SurfaceHolder holder) {
flag = true;
new Thread(this).start();
}
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
}
public void surfaceDestroyed(SurfaceHolder holder) {
flag = false;
}
private void draw(){
try{
canvas = holder.lockCanvas();
synchronized (canvas) {
canvas.drawBitmap(background, 0, 0, paint);
canvas.drawColor(Color.BLACK);
canvas.drawBitmap(blackline, 20, 100, paint);
canvas.drawBitmap(light, 20+clipx-foot, 100, paint);
canvas.clipRect(new Rect(20, 100, 20+clipx, 100+light.getHeight()));
canvas.drawBitmap(whiteline, 20,100, paint);
}
}finally{
if(canvas != null){
holder.unlockCanvasAndPost(canvas);
}
}
}
public void run() {
while(flag && !Thread.currentThread().isInterrupted()){
if(clipx >= blackline.getWidth()){
clipx = blackline.getWidth();
//此处考虑去掉亮点,可以自己定义去掉时的clipx
flag = false;
if(ofl != null){
ofl.onSetFinishLinstener();
}
}else{
clipx += foot;
}
System.out.println("---"+clipx);
draw();
try{
Thread.sleep(delay);
}catch(Exception e){
e.printStackTrace();
Thread.currentThread().interrupt();
}
}
}
public void setOnFinishLinstener(onFinishLinstener ofl) {
this.ofl = ofl;
}
public interface onFinishLinstener{
public void onSetFinishLinstener();
}
}
ProgressBar_Color.javapackage com.android.chen.main;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
public class ProgressActivity extends Activity {
private ProgressBar progress;
private ImageView image;
private Handler mHandler;
private LayoutParams lp;
private float pro = 0;
private double a;
private double width;
private double offest;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.selfdef1);
progress = (ProgressBar) findViewById(R.id.myProgress);
image = (ImageView) findViewById(R.id.image);
mHandler = new Handler();
new Thread(new Runnable() {
public void run() {
while (pro < progress.getMax()) {
pro += 1;
a = pro / progress.getMax();
width = progress.getWidth();
offest = a * width - image.getWidth() / 2;
Log.d("isRun", "a--->" + a + "width ------>" + width
+ "offest ------->" + offest);
try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
mHandler.post(new Runnable() {
public void run() {
if (offest >= 30
&& offest <= progress.getWidth() - 90) {
lp = new LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
lp.setMargins((int) offest, 5, 0, 0);
lp.addRule(RelativeLayout.CENTER_VERTICAL);
image.setVisibility(View.VISIBLE);
image.setLayoutParams(lp);
} else if(offest > progress.getWidth() - 90){
image.setVisibility(View.GONE);
pro = 0;
finish();
}
progress.setProgress((int) pro);
}
});
}
}
}).start();
}
}
ProgressBar_Indeter.javapackage com.android.chen.main;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.ProgressBar;
import com.android.chen.util.IntentUtils;
/**
* <一句话功能简述>从左向右运动的自定义颜色进度条<BR>
* <功能详细描述>
*
* @author chenli
* @version [版本号, 2011-4-8]
* @see [相关类/方法]
* @since [产品/模块版本]
*/
public class ProgressBar_Color extends Activity
{
/**
* 进度条
*/
private ProgressBar mColor = null;
/**
* 当前进度的值
*/
private int mCount = 0;
/**
* Handler消息处理
*/
private Handler mHandler = new Handler()
{
@Override
public void handleMessage(Message msg)
{
if (msg.what == IntentUtils.HANDLER_LEFT)
{
finish();
}
super.handleMessage(msg);
}
};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.mypage_color);
showIndeterDialog();
}
/**
* <一句话功能简述>展示进度条的进度<BR>
* <功能详细描述>
*
* @see [类、类#方法、类#成员]
*/
private void showIndeterDialog()
{
mCount = 0;
mColor = (ProgressBar) findViewById(R.id.progress_horizontal_color);
mColor.setMax(100);
mColor.setProgress(0);
mColor.setIndeterminate(false);
new Thread()
{
public void run()
{
try
{
while (mCount <= 100)
{
mColor.setProgress(mCount++);
Thread.sleep(100);
}
if (mCount > 100)
{
mHandler.sendEmptyMessage(IntentUtils.HANDLER_LEFT);
}
}
catch (Exception ex)
{
}
}
}.start();
}
}
ProgressBar_Left.javapackage com.android.chen.main;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.ProgressBar;
import com.android.chen.util.IntentUtils;
/**
* <一句话功能简述>不定进度的进度条<BR>
* <功能详细描述>
*
* @author chenli
* @version [版本号, 2011-4-8]
* @see [相关类/方法]
* @since [产品/模块版本]
*/
public class ProgressBar_Indeter extends Activity
{
/**
* Handler消息处理
*/
private Handler mHandler = new Handler()
{
@Override
public void handleMessage(Message msg)
{
if (msg.what == IntentUtils.HANDLER_INDETER)
{
finish();
}
super.handleMessage(msg);
}
};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.mypage_indeter);
// 延时发送消息
mHandler.sendEmptyMessageDelayed(IntentUtils.HANDLER_INDETER, 3000);
}
}
ProgressBar_Right.javapackage com.android.chen.main;
import android.app.Activity;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.ProgressBar;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import com.android.chen.util.IntentUtils;
/**
* <一句话功能简述>从左向右运动的进度条<BR>
* <功能详细描述>
*
* @author chenli
* @version [版本号, 2011-4-8]
* @see [相关类/方法]
* @since [产品/模块版本]
*/
public class ProgressBar_Left extends Activity {
/**
* 进度条
*/
private ProgressBar mLeft = null;
/**
* 当前进度的值
*/
private SeekBar mSeekBar = null;
Context mContext;
/**
* Handler消息处理
*/
private Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
if (msg.what == IntentUtils.HANDLER_LEFT) {
mLeft.setIndeterminate(true);
}
super.handleMessage(msg);
}
};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mypage_left);
mContext = this;
showIndeterDialog();
}
/**
* <一句话功能简述>展示进度条的进度<BR>
* <功能详细描述>
*
* @see [类、类#方法、类#成员]
*/
private void showIndeterDialog() {
mLeft = (ProgressBar) findViewById(R.id.progress_horizontal_left);
mSeekBar = (SeekBar) findViewById(R.id.seekBar);
mLeft.setMax(100);
mLeft.setProgress(0);
mLeft.setIndeterminate(false);
mSeekBar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
// TODO Auto-generated method stub
mLeft.setProgress(progress);
// mHandler.sendEmptyMessage(IntentUtils.HANDLER_LEFT);
}
});
}
}
ProgressDemoActivity.javapackage com.android.chen.main;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.ProgressBar;
import com.android.chen.util.IntentUtils;
/**
* <一句话功能简述>从右向左运动的进度条<BR>
* <功能详细描述>
*
* @author chenli
* @version [版本号, 2011-4-8]
* @see [相关类/方法]
* @since [产品/模块版本]
*/
public class ProgressBar_Right extends Activity
{
/**
* 进度条
*/
private ProgressBar mRight = null;
/**
* 当前进度的值
*/
private int mCount = 0;
/**
* Handler消息处理
*/
private Handler mHandler = new Handler()
{
@Override
public void handleMessage(Message msg)
{
if (msg.what == IntentUtils.HANDLER_RIGHT)
{
finish();
}
super.handleMessage(msg);
}
};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.mypage_right);
showIndeterDialog();
}
/**
* <一句话功能简述>展示进度条的进度<BR>
* <功能详细描述>
*
* @see [类、类#方法、类#成员]
*/
private void showIndeterDialog()
{
mCount = 100;
mRight = (ProgressBar) findViewById(R.id.progress_horizontal_right);
mRight.setMax(100);
mRight.setProgress(0);
mRight.setIndeterminate(false);
new Thread()
{
public void run()
{
try
{
while (mCount >= 0)
{
mRight.setProgress(mCount--);
Thread.sleep(100);
}
if (mCount < 0)
{
mHandler.sendEmptyMessage(IntentUtils.HANDLER_RIGHT);
}
}
catch (Exception ex)
{
}
}
}.start();
}
}
package com.android.chen.main;
import com.android.chen.main.Progress.onFinishLinstener;
import android.app.Activity;
import android.os.Bundle;
public class ProgressDemoActivity extends Activity {
private Progress progress;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
progress = new Progress(this);
setContentView(progress);
progress.setOnFinishLinstener(new onFinishLinstener() {
@Override
public void onSetFinishLinstener() {
// TODO Auto-generated method stub
finish();
}
});
}
}
SelfDefProgressActivity.java
VerticalPic.javapackage com.android.chen.main;
import android.app.Activity;
import android.graphics.drawable.ClipDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
import android.view.animation.TranslateAnimation;
import android.widget.AbsoluteLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;
public class SelfDefProgressActivity extends Activity {
private ImageView mView;
ImageView mImageView01;
int a = 6;
int ScreenY;
ClipDrawable cd;
@SuppressWarnings("deprecation")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.selfdef);
Toast.makeText(this, "SelfDefProgressActivity", 0).show();
/*
* ImageView iv=(ImageView) findViewById(R.id.iv_c);
* iv.setVisibility(View.VISIBLE);
* iv.setAnimation(outToRightAnimation()); //iv.setScaleType(scaleType);
* LayoutParams params = new LayoutParams(params); params.x =
* -80;//设置x坐标 params.y = -60;//设置y坐标 iv.setLayoutParams(new
* LayoutParams(arg0))
*/
/* 取得屏幕对象 */
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
/* 取得屏幕解析像素 */
int ScreenX = dm.widthPixels;
ScreenY = dm.heightPixels;
Toast.makeText(
this,
"" + ScreenX + ":" + ScreenY + " "
+ (ScreenY / 2 - ((ScreenY * 22) / 480)), 1).show();
Log.d("b", ScreenX + ":" + ScreenY);
mImageView01 = (ImageView) findViewById(R.id.iv_c);
mImageView01.setVisibility(View.VISIBLE);
mImageView01.setLayoutParams(new AbsoluteLayout.LayoutParams(20, 20,
(int) 100, 100));
mView = new ImageView(this) {
{
setImageResource(R.drawable.clip_bitmap_4);
setBackgroundResource(R.drawable.clip_btimap_content2);
cd = (ClipDrawable) getDrawable();
cd.setLevel(100);
setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (cd.getLevel() >= 9500) {
a = 6;
cd.setLevel(100);
}
cd.setLevel(cd.getLevel() + 100);
}
});
mHandler.sendEmptyMessageDelayed(1, 100);
}
};
((LinearLayout) findViewById(R.id.self_layout)).addView(mView);
}
private final Handler mHandler = new Handler() {
public void handleMessage(android.os.Message msg) {
if (mView != null) {
a += 3;
if (a > 308) {
a = 9;
cd.setLevel(10000);
}
// Log.e("b","a="+a+":v="+cd.getLevel());12/480=x/y
mImageView01
.setLayoutParams(new AbsoluteLayout.LayoutParams(20,
20, (int) a,
(ScreenY / 2 - ((ScreenY * 6) / 480))));
mView.performClick();
// mView.setOnTouchListener(l);
// mView.dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(),
// SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, 300,
// 200, 0));
sendEmptyMessageDelayed(1, 100);
}
};
};
protected Animation outToRightAnimation() {
Animation outtoRight = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, -1.0f,
Animation.RELATIVE_TO_PARENT, +1.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f);
outtoRight.setDuration(2000);
// outtoRight.setStartOffset(startOffset)
outtoRight.setInterpolator(new LinearInterpolator());
outtoRight.setRepeatCount(Animation.INFINITE);
return outtoRight;
}
}
IntentUtils.javapackage com.android.chen.main;
import com.android.chen.util.IntentUtils;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.ProgressBar;
public class VerticalPic extends Activity {
/** Called when the activity is first created. */
ProgressBar pb ;
/**
* 进度条
*/
private ProgressBar mColor = null;
/**
* 当前进度的值
*/
private int mCount = 0;
/**
* Handler消息处理
*/
private Handler mHandler = new Handler()
{
@Override
public void handleMessage(Message msg)
{
if (msg.what == IntentUtils.HANDLER_LEFT)
{
finish();
}
super.handleMessage(msg);
}
};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.vertical_process);
showIndeterDialog();
}
/**
* <一句话功能简述>展示进度条的进度<BR>
* <功能详细描述>
*
* @see [类、类#方法、类#成员]
*/
private void showIndeterDialog()
{
mCount = 0;
mColor = (ProgressBar) findViewById(R.id.pb);
mColor.setMax(100);
mColor.setProgress(0);
mColor.setIndeterminate(false);
new Thread()
{
public void run()
{
try
{
while (mCount <= 100)
{
mColor.setProgress(mCount++);
Thread.sleep(100);
}
if (mCount > 100)
{
mHandler.sendEmptyMessage(IntentUtils.HANDLER_LEFT);
}
}
catch (Exception ex)
{
}
}
}.start();
}
}
xml布局文件:package com.android.chen.util;
import android.content.Context;
import android.content.Intent;
/**
* <一句话功能简述>Intent工具类<BR>
* <功能详细描述>
*
* @author chenli
* @version [版本号, 2011-4-8]
* @see [相关类/方法]
* @since [产品/模块版本]
*/
public class IntentUtils
{
/**
* 从左向右
*/
public static final int HANDLER_LEFT = 0;
/**
* 从右向左
*/
public static final int HANDLER_RIGHT = 1;
/**
* 不确定进度
*/
public static final int HANDLER_INDETER = 2;
/**
* IntentUtils单例
*/
private static IntentUtils mIntentUtils;
/**
* <一句话功能简述>获取IntentUtils单例<BR>
* <功能详细描述>
*
* @return
* @see [类、类#方法、类#成员]
*/
public static IntentUtils getInstance()
{
if (mIntentUtils == null)
{
mIntentUtils = new IntentUtils();
}
return mIntentUtils;
}
/**
* <一句话功能简述>Intent页面跳转<BR>
* <功能详细描述>
*
* @param context
* @param mclass
* @see [类、类#方法、类#成员]
*/
public void intentForward(Context context, Class<?> mclass)
{
Intent intent = new Intent();
intent.setClass(context, mclass);
context.startActivity(intent);
}
}
main.xml
loading_process_dialog_anim.xml<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:gravity="center">
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/listview"
>
</ListView>
</LinearLayout>
loading_process_dialog_color.xml<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="wrap_content"
android:background="@color/brown"
android:layout_height="wrap_content" android:gravity="center">
<ProgressBar android:id="@+id/loading_process_dialog_progressBar"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:indeterminate="false" android:indeterminateDrawable="@anim/loading" />
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/loading" />
</LinearLayout>
loading_process_dialog_icon.xml<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/brown"
android:gravity="center"
android:orientation="horizontal" >
<ProgressBar
android:id="@+id/loading_process_dialog_progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="false"
android:indeterminateDrawable="@drawable/dialog_style_xml_color" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/loading" />
</LinearLayout>
mypage_color.xml<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/brown"
android:gravity="center"
android:orientation="horizontal" >
<ProgressBar
android:id="@+id/loading_process_dialog_progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="false"
android:indeterminateDrawable="@drawable/dialog_style_xml_icon" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/loading" />
</LinearLayout>
mypage_indeter.xml<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical" >
<ProgressBar
android:id="@+id/progress_horizontal_color"
style="@style/progressBarHorizontal_color"
android:layout_width="200dip"
android:layout_height="10dip"
android:indeterminate="true"
android:max="100"
android:progress="41" />
</LinearLayout>
mypage_left.xml<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical" >
<ProgressBar
android:id="@+id/progress_horizontal_indeter"
style="@style/progressBarHorizontal_indeter"
android:layout_width="200dip"
android:layout_height="10dip"
android:indeterminate="true"
android:max="100"
android:progress="41" />
</LinearLayout>
mypage_right.xml<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical" >
<ProgressBar
android:id="@+id/progress_horizontal_left"
style="@style/progressBarHorizontal"
android:layout_width="200dip"
android:layout_height="10dip"
android:max="100"
android:progress="41" />
<SeekBar
android:id="@+id/seekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
selfdef.xml<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:gravity="center">
<ProgressBar android:id="@+id/progress_horizontal_right"
style="@style/progressBarHorizontal_arabia" android:layout_width="200dip"
android:layout_height="10dip" android:max="100" android:progress="41" />
</LinearLayout>
selfdef1.xml<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:background="@drawable/bg"
>
<RelativeLayout
android:id="@+id/rl_body_account"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:paddingTop="30dip"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center"
android:id="@+id/self_layout"
>
</LinearLayout>
</RelativeLayout>
<ImageView
android:id="@+id/iv_c"
android:src="http://ranfeng0610.blog.163.com/blog/@drawable/c"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
/>
</AbsoluteLayout>
vertical_process.xml<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/bg">
<ProgressBar
android:id="@+id/myProgress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:max="200"
android:progressDrawable="@drawable/progress_drawable" />
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:visibility="gone"
android:background="@drawable/c" />
</RelativeLayout>
item.xml<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical" >
<ProgressBar android:id="@+id/pb"
style="?android:attr/progressBarStyleHorizontal"
android:background="@drawable/progress_bg"
android:progressDrawable="@drawable/progress_vertical"
android:layout_width="100dp"
android:layout_height="80dp"/>
</LinearLayout>
drawable下的文件:<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:id="@+id/type"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:text="@string/color"
android:gravity="center_vertical"
/>
</LinearLayout>
clip_bitmap_4.xml
clip_btimap_content2.xml<?xml version="1.0" encoding="utf-8"?>
<clip
xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/a2"
android:clipOrientation="horizontal"
android:gravity="left"/>
dialog_style_xml_color.xml<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:insetTop="0dp"
android:insetLeft="0dp"
android:insetRight="0dp"
android:insetBottom="0dp"
>
<bitmap android:gravity="center"
android:src="http://ranfeng0610.blog.163.com/blog/@drawable/a1" />
</inset>
dialog_style_xml_icon.xml<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:pivotX="50%" android:pivotY="50%" android:fromDegrees="0"
android:toDegrees="360">
<shape android:shape="ring" android:innerRadiusRatio="3"
android:thicknessRatio="8" android:useLevel="false">
<gradient android:type="sweep" android:useLevel="false"
android:startColor="#FFFFFF" android:centerColor="#FFDC35"
android:centerY="0.50" android:endColor="#CE0000" />
</shape>
</rotate>
<!--
<layer-list
xmlns:android="http://schemas.android.com/apk/res/android"> <item>
<rotate android:drawable="@drawable/dialog_progress_round"
android:fromDegrees="0.0" android:toDegrees="360.0"
android:pivotX="50.0%" android:pivotY="50.0%" /> </item> </layer-list>
-->
progress_drawable.xml<?xml version="1.0" encoding="utf-8"?>
<!--
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:pivotX="50%" android:pivotY="50%" android:fromDegrees="0"
android:toDegrees="360"> <shape android:shape="ring"
android:innerRadiusRatio="3" android:thicknessRatio="8"
android:useLevel="false"> <gradient android:type="sweep"
android:useLevel="false" android:startColor="#FFFFFF"
android:centerColor="#FFDC35" android:centerY="0.50"
android:endColor="#CE0000" /> </shape> </rotate>
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<rotate android:drawable="@drawable/dialog_progress_round"
android:fromDegrees="0.0" android:toDegrees="360.0" android:pivotX="50.0%"
android:pivotY="50.0%" />
</item>
</layer-list>
progress_vertical.xml<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@android:id/background"
android:drawable="@drawable/a1"/>
<item
android:id="@android:id/progress"
android:drawable="@drawable/a2"/>
</layer-list>
anim下文件:<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!--
<item android:id="@android:id/background" >
<shape>
<corners android:radius="5dip" />
<gradient
android:startColor="#fff"
android:endColor="#f00"
android:angle="270"
/>
</shape>
</item>
-->
<item android:id="@android:id/progress">
<clip
android:clipOrientation="vertical"
android:drawable="@drawable/progress"
android:gravity="bottom" >
<!--
<shape >
<corners android:radius="5dip" />
<gradient
android:startColor="#ffffd300"
android:centerColor="#ffffb600"
android:centerX="0.75"
android:endColor="#ffffcb00"
android:angle="90"
/>
</shape>
-->
</clip>
</item>
</layer-list>
loading.xml
values下文件:<?xml version="1.0" encoding="UTF-8"?>
<animation-list android:oneshot="false"
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:duration="150" android:drawable="@drawable/loading_01" />
<item android:duration="150" android:drawable="@drawable/loading_02" />
<item android:duration="150" android:drawable="@drawable/loading_03" />
<item android:duration="150" android:drawable="@drawable/loading_04" />
<item android:duration="150" android:drawable="@drawable/loading_05" />
<item android:duration="150" android:drawable="@drawable/loading_06" />
<item android:duration="150" android:drawable="@drawable/loading_07" />
</animation-list>
color.xml
strings.xml<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="brown">#947400</color> <!-- 棕色 -->
</resources>
styles.xml<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, Testp!</string>
<string name="app_name">Testp</string>
<string name="yinlian">银联支付进度条</string>
<string name="color">水平自定义颜色进度条</string>
<string name="left">水平自左向右的进度条</string>
<string name="right">水平自右向左的进度条</string>
<string name="indeter">水平不确定的进度条</string>
<string name="vertical_pic">垂直图片进度条</string>
<string name="round_anim">圆形动画进度条</string>
<string name="round_color">圆形颜色进度条</string>
<string name="round_pic">圆形图片进度条</string>
<string name="loading">正在加载数据请稍后……</string>
</resources>
图片资源:<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2006 The Android Open Source Project Licensed under the
Apache License, Version 2.0 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for
the specific language governing permissions and limitations under the
License.
-->
<resources>
<!-- 下载进度条样式 -->
<style name="progressBarHorizontal_color" parent="android:Widget.ProgressBar.Horizontal">
<item name="android:indeterminateOnly">false</item>
<item name="android:progressDrawable">@drawable/progress_color_horizontal</item>
<item name="android:minHeight">5dip</item>
<item name="android:maxHeight">5dip</item>
</style>
<style name="progressBarHorizontal" parent="android:Widget.ProgressBar.Horizontal">
<item name="android:indeterminateOnly">false</item>
<item name="android:progressDrawable">@drawable/progress_horizontal</item>
<item name="android:minHeight">5dip</item>
<item name="android:maxHeight">5dip</item>
</style>
<style name="progressBarHorizontal_arabia" parent="android:Widget.ProgressBar.Horizontal">
<item name="android:indeterminateOnly">false</item>
<item name="android:progressDrawable">@drawable/progress_horizontal_arabia</item>
<item name="android:minHeight">5dip</item>
<item name="android:maxHeight">5dip</item>
</style>
<style name="progressBarHorizontal_indeter" parent="android:Widget.ProgressBar.Horizontal">
<item name="android:indeterminateOnly">false</item>
<item name="android:indeterminateDrawable">@drawable/progress_indeterminate_horizontal</item>
<item name="android:minHeight">5dip</item>
<item name="android:maxHeight">5dip</item>
</style>
</resources>
注意:在做Android4.0的开发时,发现AlertDialog相比较以前有了较大变化,就是在触摸对话框边缘外部,对话框消失
于是研究其父类发现,可以设置这么一条属性,当然必须先AlertDialog.Builder.create()之后才能调用这两个方法
方法一:
setCanceledOnTouchOutside(false);调用这个方法时,按对话框以外的地方不起作用。按返回键还起作用
方法二:
setCanceleable(false);调用这个方法时,按对话框以外的地方不起作用。按返回键也不起作用
这两个方法都属于Dialog方法,可自行查阅SDK
- 各种进度条效果
- 各种经典的进度条效果
- Android 常用效果(各种进度条,酷炫loading动画,火箭升空,撒花以及趋势图)
- Android 常用效果(各种进度条,酷炫loading动画,火箭升空,撒花以及趋势图)
- Android 常用效果(各种进度条,酷炫loading动画,火箭升空,撒花以及趋势图)
- Android 常用效果(各种进度条,酷炫loading动画,火箭升空,撒花以及趋势图)
- 进度条实现---各种方式
- 各种进度条的介绍
- Bootstrap 各种进度条详解
- 各种效果
- 渐变效果进度条
- 网页中的进度条效果
- js进度条效果
- PHP进度条效果
- 实现 进度条效果 实例
- js实现进度条效果
- ext 实现进度条效果
- JS实现进度条效果
- 类似优酷首页下面分类视频的效果
- 数据备份、重建索引、检查数据库,删除备份
- 删除listview多个item时的小问题
- 获取状态栏高度
- 4.0模拟器 编辑框不自动弹出软键盘问题
- 各种进度条效果
- Android Please ensure that adb is correctly located at问题解决
- Android中集成第三方的分享和版本更新以及用户量统计
- 获取指定目录下所有的子目录和文件
- spket插件的安装与使用完整图文版
- 设计并实现同时支持多种视频格式的流媒体点播系统
- Adobe Photoshop CS5破解
- VS2010进行远程调试方法总结
- linux怎么查看计算机配置