android进度条

1、达到的效果

2、布局代码

先写一个my_browser.xml文件 存放WebView

<?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:orientation="vertical" > <WebView
android:id="@+id/webView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>

进度条布局

然后写一个broser.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">
<TextView
android:id="@+id/tvtitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="true"
android:singleLine="true"
android:ellipsize="marquee"
android:focusable="false"
android:marqueeRepeatLimit="marquee_forever"
android:textSize="20sp" android:layout_centerVertical="true"/>
<ProgressBar
android:id="@+id/pb"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyleHorizontal"
android:visibility="gone"
android:layout_alignParentBottom="true" >
</ProgressBar> </RelativeLayout>

WebChromeClient

重写onProgressChanged和onReceivedTitle事件(进度条载入完毕后使用动画渐退)

/**
* MyWebChromeClient.java
* 版权全部(C) 2012
 * 创建:cuiran 2012-10-16 下午3:05:34
*/
package com.cayden.citygirl.activity; import android.app.Activity;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.widget.ProgressBar;
import android.widget.TextView; /**
* TODO
* @author cuiran
* @version TODO
*/
public class MyWebChromeClient extends WebChromeClient { private Activity activity; private ProgressBar pb; private Animation animation; private TextView tvtitle; public MyWebChromeClient(Activity activity) { this.activity = activity; } @Override
public void onProgressChanged(WebView view, int newProgress) {
pb=(ProgressBar)activity.findViewById(R.id.pb);
pb.setMax(100);
if(newProgress<100){
if(pb.getVisibility()==View.GONE) pb.setVisibility(View.VISIBLE);
pb.setProgress(newProgress);
}else{
pb.setProgress(100);
animation=AnimationUtils.loadAnimation(activity, R.anim.animation);
// 执行动画
pb.startAnimation(animation);
// 将 spinner 的可见性设置为不可见状态
pb.setVisibility(View.INVISIBLE);
}
super.onProgressChanged(view, newProgress);
}
@Override
public void onReceivedTitle(WebView view, String title) { tvtitle=(TextView)activity.findViewById(R.id.tvtitle); tvtitle.setText(title);
super.onReceivedTitle(view, title); } }

进度条的动画样式 res/anim/animation.xml

<?

xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha android:fromAlpha="1.0"
android:toAlpha="0.0"
android:duration="700"/>
</set>

5、程序启动类

/**
* ProgressActivity.java
* 版权全部(C) 2012
* 创建:cuiran 2012-10-16 下午3:13:49
*/
package com.cayden.citygirl.activity; import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.webkit.WebView; /**
* TODO
* @author cuiran
* @version TODO
*/
public class ProgressActivity extends Activity { private WebView browser;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.my_browser); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.broser); browser = (WebView) findViewById(R.id.webView); // currentWebView=browser; browser.setWebChromeClient(new MyWebChromeClient(ProgressActivity.this)); browser.loadUrl("http://shop.paipai.com/731681975/"); } }

android进度条的更多相关文章

  1. 多种的android进度条的特效源码

    多种的android进度条的特效源码,这个源码是在源码天堂那个网站上转载过来的,我已经修改一部分了,感觉很实用的,大家可以学习一下吧,我就不上传源码了,大家可以直接到那个网站上下载吧. 源码天堂下载地 ...

  2. Android 进度条改变图片透明度

    <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...

  3. Android 进度条

    <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...

  4. Android—进度条

    layout文件: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:an ...

  5. Android——进度条ProgressBar

    1.activity_progressbar.xml <?xml version="1.0" encoding="utf-8"?><Linea ...

  6. android进度条的使用

    // 导入按钮事件  btnsearch.setOnClickListener(new View.OnClickListener() {      @Override   public void on ...

  7. Android 进度条按钮实现(ProgressButton)

    有些App在点击下载按钮的时候,可以在按钮上显示进度,我们可以通过继承原生Button,重写onDraw来实现带进度条的按钮. Github:https://github.com/imcloudflo ...

  8. Android 进度条对话框ProgressDialog

    <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=&quo ...

  9. Android进度条控件ProgressBar使用

    ProgressBar有四种样式,圆形的(大,中,小)和直条形的(水平) 对应的style为 <LinearLayout xmlns:android="http://schemas.a ...

随机推荐

  1. LightOJ1010---Knights in Chessboard (规律题)

    Given an m x n chessboard where you want to place chess knights. You have to find the number of maxi ...

  2. mysql 多个字段拼接

    Mysql的查询结果行字段拼接,能够用以下两个函数实现: 1. concat函数 mysql> select concat('1','2','3') from test ; +--------- ...

  3. JS于string 和 json互转对象

    一.json开启string JSON.stringify(jsonObj) 两.string开启json eval(string) 版权声明:本文博主原创文章.博客,未经同意不得转载.

  4. ACM:图BFS,迷宫

    称号: 网络格迷宫n行m单位列格组成,每个单元格无论空间(使用1表示),无论是障碍(使用0为了表示).你的任务是找到一个动作序列最短的从开始到结束,其中UDLR同比分别增长.下一个.左.向右移动到下一 ...

  5. [Python 学习] 两、在Linux使用平台Python

    在本节,它介绍了Linux如何使用平台Python 1. Python安装. 今天,大多数把自己的版本号Python的,它不能被安装.假设你要安装它,可以使用相应的安装指令. Fedora:先以roo ...

  6. android详情请务必保持手机屏幕不锁屏

    今天做这个项目采用了非常有趣的东西,互联网搜索下一个轮廓,需求就是点击一个按钮来锁定屏幕让屏幕不亮. 几个测试.我们发现以下措辞如此简单, getWindow().addFlags(WindowMan ...

  7. Nginx搭建反向代理服务器过程详解(转)

    一.反向代理 我们都知道,80端口是web服务的默认端口,其他主机访问web服务器也是默认和80端口进行web交互,而一台服务器也只有一个80端口,这是约定俗成的标准. 我们来看下面两个场景: 1.服 ...

  8. NSIS 自定义页面制作关闭功能

    因工作需要要自定义NSIS的安装页面,其中用到一个功能. 修改的是这个项目:https://github.com/nicecai/nsissource http://hamletsoft.com/ 在 ...

  9. Android系统关机或几种方式重启

    ---------------------------------------------------------------------------------------------------- ...

  10. ASP.NET开发规范:OWIN

    ASP.NET开发规范:OWIN 今天投简历 准备面试了... 本节目录: OWIN简介 OWIN规范 Katana Hello World(3种Host) 自定义Middleware OWIN简介 ...