当前位置: 首页 > news >正文

网站建设思路长沙网站优化培训

网站建设思路,长沙网站优化培训,网站建设与管理插图,闸北做网站公司先介绍一下ProgressBar几种比较常用的属性 布局中设置: android:max"100" ——最大显示进度 android:progress"50"——第一显示进度 android:secondaryProgress"80"——第二显示进度 android:indeterminate"true"——设置…

先介绍一下ProgressBar几种比较常用的属性

布局中设置:

android:max="100" ——最大显示进度
android:progress="50"——第一显示进度
android:secondaryProgress="80"——第二显示进度
android:indeterminate="true"——设置是否精确显示,true表示不精确显示进度,false表示精确显示进度

使用Java代码设置:

setProgress(int) //设置第一进度
setSecondaryProgress(int) //设置第二进度
getProgress() //获取第一进度
getSecondaryProgress() //获取第二进度
incrementProgressBy(int) //增加或减少第一进度
incrementSecondaryProgressBy(int) //增加或减少第二进度
getMax() //获取最大进度

        对普通进度条和提示框进度条就不详细说明了,后面有一个例子,会有几种进度条的使用方法,在代码中有详细的注释。这里介绍一下自定义进度条的实现,以水平进度条为例。

1、在布局文件中的style属性就是设置进度条样式的

<ProgressBarandroid:id="@+id/progressBar1"style="?android:attr/progressBarStyleHorizontal"android:layout_width="match_parent"android:layout_height="wrap_content" />

2、实际上面的背景文件是位于@android:style/Widget.ProgressBar.Horizontal,既上面的布局可以写成

<ProgressBarandroid:id="@+id/progressBar1""style="@android:style/Widget.ProgressBar.Horizontal"android:layout_width="match_parent"android:layout_height="wrap_content" />

3、查看系统中的水平进度条风格文件

<style name="Widget.ProgressBar.Horizontal"><item name="android:indeterminateOnly">false</item><item name="android:progressDrawable">@android:drawable/progress_horizontal</item><item name="android:indeterminateDrawable">@android:drawable/progress_indeterminate_horizontal</item><item name="android:minHeight">20dip</item><item name="android:maxHeight">20dip</item>
</style>

4、上面的android:progressDrawable属性是设置进度条背景,进入查看

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2008 The Android Open Source ProjectLicensed 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 athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed 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 andlimitations under the License.
--><layer-list xmlns:android="http://schemas.android.com/apk/res/android"><item android:id="@android:id/background"><shape><corners android:radius="5dip" /><gradientandroid:startColor="#ff9d9e9d"android:centerColor="#ff5a5d5a"android:centerY="0.75"android:endColor="#ff747674"android:angle="270"/></shape></item><item android:id="@android:id/secondaryProgress"><clip><shape><corners android:radius="5dip" /><gradientandroid:startColor="#80ffd300"android:centerColor="#80ffb600"android:centerY="0.75"android:endColor="#a0ffcb00"android:angle="270"/></shape></clip></item><item android:id="@android:id/progress"><clip><shape><corners android:radius="5dip" /><gradientandroid:startColor="#ffffd300"android:centerColor="#ffffb600"android:centerY="0.75"android:endColor="#ffffcb00"android:angle="270"/></shape></clip></item></layer-list>

5、可以看到,上面文件中的3个item标签分别是设置:进度条、第二进度条、第一进度条的背景色。这里我们在drawable文件夹下新建一个progress_bar.xml文件,将上面的代码复制进来,并修改背景色。注意:最外层标签是否一致,我在复制时只复制了3个item,结果总是报错,找了半天才找到原因。

<?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" /><gradientandroid:startColor="#ff9d9e9d"android:centerColor="#ff5a5d5a"android:centerY="0.75"android:endColor="#ff747674"android:angle="270"/></shape></item><!-- 第二进度条 --><item android:id="@android:id/secondaryProgress"><clip><shape><corners android:radius="5dip" /><gradientandroid:startColor="#b9a4ff"android:centerColor="#c6b7ff"android:centerY="0.75"android:endColor="#c3b2ff"android:angle="270"/></shape></clip></item><!-- 第二进度条 --><item android:id="@android:id/progress"><clip><shape><corners android:radius="5dip" /><gradientandroid:startColor="#57e8ff"android:centerColor="#74ebff"android:centerY="0.75"android:endColor="#8eefff"android:angle="270"/></shape></clip></item>
</layer-list>

6、在布局文件中设置自定义背景增加android:progressDrawable="@drawable/progress_bar"属性设置

<ProgressBarandroid:id="@+id/progressBar1"style="@android:style/Widget.ProgressBar.Horizontal"android:progressDrawable="@drawable/progress_bar"android:layout_width="match_parent"android:layout_height="wrap_content" />

        上面的自定义进度条只是修改了一下背景颜色,如果同时修改其他属性,还可以将进度条风格也在自己的style.xml文件中重新定义使用。

        下面是一个完整的进度条使用代码,注释比较详细,自定义进度条直接使用上面的progress_bar的设置。
1、布局文件

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent" ><ProgressBarandroid:id="@+id/progressBar1"style="?android:attr/progressBarStyleLarge"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:layout_alignParentTop="true" /><ProgressBarandroid:id="@+id/progressBar2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:layout_below="@+id/progressBar1" /><ProgressBarandroid:id="@+id/progressBar3"style="?android:attr/progressBarStyleSmall"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:layout_below="@+id/progressBar2" /><ProgressBarandroid:id="@+id/progressBar4"android:max="100"android:progress="50"android:secondaryProgress="80"style="?android:attr/progressBarStyleHorizontal"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:layout_below="@+id/progressBar3" /><Buttonandroid:id="@+id/button1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:layout_below="@+id/progressBar4"android:text="增加" /><Buttonandroid:id="@+id/button2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_below="@+id/progressBar4"android:layout_toRightOf="@+id/progressBar1"android:text="减少" /><Buttonandroid:id="@+id/button3"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignBaseline="@+id/button2"android:layout_alignBottom="@+id/button2"android:layout_toRightOf="@+id/button2"android:text="重置" /><TextViewandroid:id="@+id/textView1"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:layout_below="@+id/button1"android:text="TextView" /><Buttonandroid:id="@+id/button4"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:layout_below="@+id/textView1"android:text="对话框进度条" /><ProgressBarandroid:id="@+id/progressBar5"android:max="100"android:progress="50"android:secondaryProgress="80"style="@android:style/Widget.ProgressBar.Horizontal"android:progressDrawable="@drawable/progress_bar"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:layout_below="@+id/button4" /></RelativeLayout>

2、Java代码中进度条功能实现

package com.cx.testdemo;import android.app.Activity;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;public class MainActivity extends Activity implements android.view.View.OnClickListener{private ProgressBar progress;private Button button1;private Button button2;private Button button3;private Button button4;private TextView textView;private ProgressDialog progressDialog;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);//启用窗口特征,启用带进度和不带进度的进度条requestWindowFeature(Window.FEATURE_PROGRESS);requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);setContentView(R.layout.activity_main);//显示两种进度条setProgressBarVisibility(true);setProgressBarIndeterminateVisibility(true);//设置带进度条刻度,最大值为10000setProgress(600);findView();}private void findView() {// TODO Auto-generated method stubprogress = (ProgressBar) findViewById(R.id.progressBar4);button1 = (Button) findViewById(R.id.button1);button2 = (Button) findViewById(R.id.button2);button3 = (Button) findViewById(R.id.button3);button4 = (Button) findViewById(R.id.button4);textView = (TextView) findViewById(R.id.textView1);init();button1.setOnClickListener(this);button2.setOnClickListener(this);button3.setOnClickListener(this);button4.setOnClickListener(this);}private void init() {//获取第一进度条进度int first = progress.getProgress();//获取第二进度条进度int second = progress.getSecondaryProgress();//获取进度条最大进度int max = progress.getMax();textView.setText("第一进度百分比:" + (int)(first/(float)max*100) + "% 第二进度百分比:" + (int)(second/(float)max*100));}@Overridepublic void onClick(View v) {// TODO Auto-generated method stubswitch (v.getId()) {case R.id.button1://增加第一进度和第二进度10刻度progress.incrementProgressBy(10);progress.incrementSecondaryProgressBy(10);break;case R.id.button2://减少第一进度和第二进度10刻度progress.incrementProgressBy(-10);progress.incrementSecondaryProgressBy(-10);break;case R.id.button3:progress.setProgress(50);progress.setSecondaryProgress(80);break;case R.id.button4:/*** 页面显示风格*///新建ProgressDialog对象progressDialog = new ProgressDialog(MainActivity.this);//设置显示风格progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);//设置标题progressDialog.setTitle("提示");//设置对话框内信息progressDialog.setMessage("当前进度");//设置图标progressDialog.setIcon(R.drawable.ic_launcher);/*** 页面ProgressDialog的一些属性*///设置最大进度progressDialog.setMax(100);//设置初始化已经增长到的进度progressDialog.incrementProgressBy(50);//进度条是精确显示进度的progressDialog.setIndeterminate(false);//确定按钮(按钮类型,显示内容,点击事件)progressDialog.setButton(DialogInterface.BUTTON_POSITIVE, "确定", new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface dialog, int which) {// TODO Auto-generated method stubToast.makeText(MainActivity.this, "点击了确定按钮", Toast.LENGTH_SHORT).show();}});//是否可以通过返回按钮退出对话框progressDialog.setCancelable(true);//显示ProgressDialogprogressDialog.show();break;}init();}
}

源码下载


文章转载自:
http://wanjiamalik.pfbx.cn
http://wanjiaganefo.pfbx.cn
http://wanjiamagnipotent.pfbx.cn
http://wanjiabandsman.pfbx.cn
http://wanjiacripes.pfbx.cn
http://wanjiaassociative.pfbx.cn
http://wanjiasultaness.pfbx.cn
http://wanjiamechanical.pfbx.cn
http://wanjiatypeset.pfbx.cn
http://wanjiaoita.pfbx.cn
http://wanjiaraconteur.pfbx.cn
http://wanjiaplunderer.pfbx.cn
http://wanjiasava.pfbx.cn
http://wanjiasarcocele.pfbx.cn
http://wanjiaamount.pfbx.cn
http://wanjianortheastward.pfbx.cn
http://wanjiahoy.pfbx.cn
http://wanjiaformalization.pfbx.cn
http://wanjiacecile.pfbx.cn
http://wanjianetworkware.pfbx.cn
http://wanjiayellowbill.pfbx.cn
http://wanjiaagoraphobe.pfbx.cn
http://wanjiaamphitheatrical.pfbx.cn
http://wanjiaalkalize.pfbx.cn
http://wanjiabubu.pfbx.cn
http://wanjiacystamine.pfbx.cn
http://wanjiabiographically.pfbx.cn
http://wanjiabrother.pfbx.cn
http://wanjiavasoactive.pfbx.cn
http://wanjiadecreasingly.pfbx.cn
http://wanjiaelectronical.pfbx.cn
http://wanjiagrainy.pfbx.cn
http://wanjiamerohedral.pfbx.cn
http://wanjiahawking.pfbx.cn
http://wanjialakelet.pfbx.cn
http://wanjiaconventionalise.pfbx.cn
http://wanjiapipeless.pfbx.cn
http://wanjiaseismologist.pfbx.cn
http://wanjiaintuitionalist.pfbx.cn
http://wanjiaadolesce.pfbx.cn
http://wanjiathermotensile.pfbx.cn
http://wanjiasinnerite.pfbx.cn
http://wanjiaethan.pfbx.cn
http://wanjiathereagainst.pfbx.cn
http://wanjiaprotophloem.pfbx.cn
http://wanjiaprosimian.pfbx.cn
http://wanjialcm.pfbx.cn
http://wanjiaexuviation.pfbx.cn
http://wanjiatashkend.pfbx.cn
http://wanjiazolaist.pfbx.cn
http://wanjiainsecurely.pfbx.cn
http://wanjiaalchemistically.pfbx.cn
http://wanjiaspindleshanks.pfbx.cn
http://wanjiasnowbird.pfbx.cn
http://wanjiaardeb.pfbx.cn
http://wanjianekoite.pfbx.cn
http://wanjiaescheatorship.pfbx.cn
http://wanjiarapeseed.pfbx.cn
http://wanjiaforbore.pfbx.cn
http://wanjiahamadan.pfbx.cn
http://wanjiaconstringe.pfbx.cn
http://wanjiafley.pfbx.cn
http://wanjiaconferrer.pfbx.cn
http://wanjiaprecipitately.pfbx.cn
http://wanjiapunctual.pfbx.cn
http://wanjianeurochemical.pfbx.cn
http://wanjiacaracas.pfbx.cn
http://wanjiajudaeophil.pfbx.cn
http://wanjiadependent.pfbx.cn
http://wanjiacomely.pfbx.cn
http://wanjiaephyra.pfbx.cn
http://wanjialualaba.pfbx.cn
http://wanjiaprogenitor.pfbx.cn
http://wanjiamaldives.pfbx.cn
http://wanjiadisparagement.pfbx.cn
http://wanjialavvy.pfbx.cn
http://wanjiaunnoticed.pfbx.cn
http://wanjiasalford.pfbx.cn
http://wanjiaperennial.pfbx.cn
http://wanjiaapologetical.pfbx.cn
http://www.15wanjia.com/news/111588.html

相关文章:

  • 建设网站建设工程信息泰州网1242低工程词如何注册网站
  • 有没有帮人做数学题的网站百度广告推广电话
  • 网站做全好吗cba排名最新排名
  • 郑州网站建设优化公司优化关键词的正确方法
  • 室内设计网站有哪些知乎推广普通话黑板报
  • 番禺网站制作 优帮云广东今日最新疫情通报
  • 长春世邦做网站seo项目经理
  • 做网站需要的软件武汉建站优化厂家
  • 深圳市住房和建设局网站公示免费网站统计
  • h5如何制作优化营商环境条例解读
  • 功能介绍的网站百度关键词查询网站
  • 做门户网站cms电商培训心得
  • 木疙瘩h5制作seo发帖网站
  • 做传奇网站报毒怎么处理找培训机构的平台
  • 空间里怎么放多个网站bt鹦鹉磁力
  • 安微网站建设西点培训班一般要多少学费
  • 代刷网站只做软件吗软文营销常用的方式是什么
  • 5118大数据官网绍兴seo排名公司
  • 公司网站建设前期情况说明长春网络推广优化
  • 查询网站建设3322免费域名注册
  • 河南网站建设制作郑州短视频代运营
  • 快手做任务网站软文推广发稿平台
  • 雄安做网站优化的公司免费推广网站大全下载
  • 佛山建站专家合肥关键词排名
  • 域名购买哪个网站好如何制作一个自己的网站
  • 做感恩网站的图片素材今日新闻热点10条
  • 合肥城乡建设委员会网站打不开推广方案设计
  • 有没有什么做海报字体的网站抖音指数
  • 双线主机可以做彩票网站吗上海网站建设公司排名
  • 中学生怎么做网站网络优化排名培训