Android银弧刀之ProgressBar之最炫民族风「建议收藏」

Android银弧刀之ProgressBar之最炫民族风「建议收藏」传送门 ☞ Android兵器谱 ☞ 转载请注明 ☞ http://blog.csdn.net/leverage_1229银弧刀     陆无双抬起头来,只见四名乞丐,一字排在门外,或高或矮,一齐望着自己。她曾用银弧刀伤了一个乞丐,一见这四人来意不善,心中暗暗吃惊。。。杨过听了她声音,也是大吃一惊,只听另一个女人声音道:“那叫化子背上的,明明是师妹的银弧刀,就可惜没能起

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺

传送门 ☞ Android兵器谱 ☞ 转载请注明 ☞ http://blog.csdn.net/leverage_1229

Android银弧刀之ProgressBar之最炫民族风「建议收藏」

银弧刀 
        陆无双抬起头来,只见四名乞丐,一字排在门外,或高或矮,一齐望着自己。她曾用银弧刀伤了一个乞丐,一见这四人来意不善,心中暗暗吃惊。。。杨过听了她声音,也是大吃一惊,只听另一个女人声音道:“那叫化子背上的,明明是师妹的银弧刀,就可惜没能起下来认一下。”

        今天我们学习如何利用Android平台“银弧刀”ProgressBar来实现各种样式的进度条,白的黄的都有^_^。实际生活中进度条常常用来提示用户后台正在执行比较耗时的操作,请等待一会儿。当操作执行完毕时,它就随风逝去了。下面给出该情景的案例:

一、案例技术要点

1.ProgressBar布局设置
style=”?android:attr/progressBarStyleSmallTitle”:小圆形进度条
style=”?android:attr/progressBarStyleLarge”:大圆形进度条
style=”?android:attr/progressBarStyleHorizontal”:水平进度条
2.设置有刻度效果的窗口
requestWindowFeature(Window.FEATURE_PROGRESS):设置窗口有进度条
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS):设置窗口有模糊进度条
setProgressBarVisibility(true):设置进度条显示
setProgressBarIndeterminate(true):设置模糊进度条显示
3.android.widget.ProgressBar:Android进度条类
progressBar.setProgress(…):设置进度条刻度值
progressBar.getProgress():获取进度条刻度值

二、案例代码陈列

工程包目录

Android银弧刀之ProgressBar之最炫民族风「建议收藏」

AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.progressbar"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="15" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".ProgressBarMainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

strings.xml

<resources>
    <string name="app_name">ProgressBar大世界</string>
</resources>

main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="小圆形进度条" />

    <ProgressBar
        style="?android:attr/progressBarStyleSmallTitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="中圆形进度条" />

    <ProgressBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="大圆形进度条" />

    <ProgressBar
        style="?android:attr/progressBarStyleLarge"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="水平进度条" />

    <ProgressBar
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:max="100"
        android:progress="30" />

    <ProgressBar
        android:id="@+id/progressBar"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:max="100"
        android:progress="30"
        android:secondaryProgress="60" />

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal" >

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="增加刻度" />

        <Button
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="减小刻度" />
    </LinearLayout>

</LinearLayout>

ProgressBarMainActivity.java

package com.android.progressbar;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.ProgressBar;

/**
 * ProgressBar案例:各种样式的进度条
 * 向用户展示当前任务的进度
 * @author lynnli1229
 */
public class ProgressBarMainActivity extends Activity implements OnClickListener{
    private ProgressBar progressBar;
    private Button button1, button2;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        // 设置有刻度效果的窗口
        requestWindowFeature(Window.FEATURE_PROGRESS);
        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
        
        setContentView(R.layout.main);
        progressBar = (ProgressBar) findViewById(R.id.progressBar);
        setProgressBarVisibility(true);
        setProgressBarIndeterminate(true);
        setProgress(3500);
        
        button1 = (Button) findViewById(R.id.button1);
        button2 = (Button) findViewById(R.id.button2);
        button1.setOnClickListener(this);
        button2.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
        case R.id.button1:
            progressBar.setProgress((int) (progressBar.getProgress() * 1.2));
            progressBar.setSecondaryProgress((int) (progressBar.getSecondaryProgress() * 1.2));
            break;

        case R.id.button2:
            progressBar.setProgress((int) (progressBar.getProgress() * 0.8));
            progressBar.setSecondaryProgress((int) (progressBar.getSecondaryProgress() * 0.8));
            break;
        }
    }
}

三、案例效果展示

Android银弧刀之ProgressBar之最炫民族风「建议收藏」 
Android银弧刀之ProgressBar之最炫民族风「建议收藏」

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/192990.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • JAVA Exception和IOException之间的使用区别

    JAVA Exception和IOException之间的使用区别使用Exception可以保证捕获异常后能继续维持JVM的运行如果Exception换成IOException后,一旦出现IO异常,便会捕获停止运行.“IoException“(流异常,通常用在文件读取中)是”Exception”(用在所有的异常处理中)的一个分支,也就是说“Exception”的范围更大。解释:通过java中在捕获异常的时候需要先捕获“子异常”(范围小,如流异常),之……

    2022年7月16日
    9
  • DropDownList绑定数据源后,要插入项的处理「建议收藏」

    DropDownList绑定数据源后,要插入项的处理「建议收藏」privatevoidBindDivision(){DivisionServicedivisionService=newDivisionService();vardivisions=divisionService.GetList(base.AdminDivisionId)…

    2022年9月1日
    2
  • date转成localdate_localdatetime转localdate

    date转成localdate_localdatetime转localdate/** *将LocalDate转为Date * *@paramlocalDate *@returnjava.util.Date */ publicstaticDatelocalDateToDate(LocalDatelocalDate){ returnDate.from(localDate.atStartOfDay(ZoneId.syste…

    2022年10月3日
    1
  • 老庄结构设计官网_互联网颗粒度的名词解释

    老庄结构设计官网_互联网颗粒度的名词解释    本文是对上篇MGN论文阅读做一个详细的补充,主要补充其结构设计及技术实现细节。文章内容整合来自云从科技资深算法研究员袁余锋老师,通过以下四个方面来讲解本次课题:1、ReID的定义及技术难点;2、常用数据集与评价指标简介;3、多粒度网络(MGN)的结构设计与技术实现;4、ReID在行人跟踪中的应用分析与技术展望ReID是行人智能认知的其中一个研究方向,行人智能认知是人脸识别之后比较重要…

    2022年10月6日
    0
  • 计算机中1kb等于多少字节,1mb等于多少kb「建议收藏」

    计算机中1kb等于多少字节,1mb等于多少kb「建议收藏」⑴计算机的储存容量1MB等于多少KB计算机的储存容量1MB=1024KB。MB,为英文“MByte”的简写,是计算机中的一种储存单位,读作“兆”。存储容量是指存储器可以容纳的二进制信息量,用存储器中存储地址寄存器MAR的编址数与存储字位数的乘积表示。网络上的所有信息都是以“位”(bit)为单位传递的,一个位就代表一个0或1。(1)1mb等于多少kb扩展阅读存储容量是便携存储产品最为关键的参数…

    2022年5月25日
    73
  • js,timeout,promise执行顺序

    js,timeout,promise执行顺序

    2022年3月13日
    75

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号