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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 提取pfx证书密钥对

    提取pfx证书密钥对两个测试证书test.pfx和test.cer.其中pfx证书包含RSA的公钥和密钥;cer证书用于提取pfx证书中密钥时允许当前电脑进行合法操作提取步骤如下:点击test.cer,安装cer证书2.从pfx提取密钥信息,并转换为key格式(pfx使用pkcs12模式补足)(1)提取密钥对opensslpkcs12-intest.pfx-nocerts-nodes-outtest.key//如果pfx证书已加密,会提示输入密码。如果cer证书没有安装

    2022年5月31日
    58
  • goland 激活码2021[免费获取]

    (goland 激活码2021)好多小伙伴总是说激活码老是失效,太麻烦,关注/收藏全栈君太难教程,2021永久激活的方法等着你。IntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,下面是详细链接哦~https://javaforall.net/100143.htmlMLZPB5EL5Q-eyJsaWNlbnNlSWQi…

    2022年3月20日
    53
  • CFileDialog的使用方法简单介绍

    CFileDialog的使用方法简单介绍

    2021年11月30日
    50
  • 使用Python获取上海详细疫情数据(一)「建议收藏」

    使用Python获取上海详细疫情数据(一)「建议收藏」抽空之余,写个小脚本,获取下上海详细的疫情数据,以作后续的详实数据分析(纯爱好),或者仅仅作为对历史的一种数据样本式的保存也未尝不可,顺便吧,缓解或者平复下情绪。阅读本文章需要读者有一定的Python基础,且对XPATH、正则、selenium有一定.

    2025年11月24日
    2
  • linux-netstat

    linux-netstat

    2022年4月2日
    65
  • Java中常用的API[通俗易懂]

    Java中常用的API[通俗易懂]1.Calendar类(日期与时间处理)使用情况:publicstaticvoidmain(String[]args){Calendarc=Calendar.getInstance();intyear=c.get(Calendar.YEAR);intmonth=c.get(Calendar.MONTH)+1;intday=c.get(Calendar.DATE);intweek

    2022年7月8日
    23

发表回复

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

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