zoukankan      html  css  js  c++  java
  • 进度条

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout 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"
        android:orientation="vertical"
        tools:context="com.hanqi.textapp2.jindutiaoActivity">
        <ProgressBar
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            style="?android:attr/progressBarStyleHorizontal"
            android:progress="50"
            android:secondaryProgress="60"
            android:max="90"
            android:id="@+id/sb2"/>
        <ProgressBar
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            style="?android:attr/progressBarStyleSmall"
            android:progress="50"
            android:secondaryProgress="60"
            android:max="255"
            android:id="@+id/sb3"
            android:visibility="visible"
            />
    
        <SeekBar
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:progress="100"
            android:secondaryProgress="60"
            android:max="255"
            android:id="@+id/sb1"/>
    
        <RatingBar
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:numStars="6"
            android:rating="3.5"
            android:isIndicator="false"/>
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/aaa"
            android:id="@+id/sb4"
            />
    
    </LinearLayout>

    视图代码

    package com.hanqi.textapp2;
    
    import android.os.Bundle;
    import android.support.v7.app.AppCompatActivity;
    import android.util.Log;
    import android.view.View;
    import android.widget.ImageView;
    import android.widget.ProgressBar;
    import android.widget.SeekBar;
    
    public class jindutiaoActivity extends AppCompatActivity {
        SeekBar sb1;
        ProgressBar sb2;
        ProgressBar sb3;
       int jd;
        ImageView sb4;
    
        //AlertDialog ad= new AlertDialog.Builder(this).create();
    
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_jindutiao);
            sb1=(SeekBar)findViewById(R.id.sb1);
            sb2=(ProgressBar)findViewById(R.id.sb2);
            sb3=(ProgressBar)findViewById(R.id.sb3);
            sb4=(ImageView)findViewById(R.id.sb4);
            //需要在java里预设一下,范围1-255
            sb4.setImageAlpha(1);
            //sb4.setAlpha(1);
    
            sb1.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                @Override
                public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                    //只要progress变化就会被触发
                    //Toast.makeText(jindutiaoActivity.this, "当前进度=" + progress, Toast.LENGTH_SHORT).show();
    
                    jd=progress;
                   // String jd2=jd+"";
                    //Float jd1=Float.parseFloat(jd2);
                    //中划线-方法废弃不建议使用
                    //sb4.setAlpha(jd/100);
                    //sb4.setAlpha(jd/100.0f);
                   //sb4.setAlpha(jd1);
    
                    //该方法版本不支持16以下的
                    //方法接收值的范围是255;
                    sb4.setImageAlpha(jd);
    
                   // Toast.makeText(jindutiaoActivity.this, "当前进度="+sb4.getAlpha(), Toast.LENGTH_SHORT).show();
    
                    sb2.setProgress(jd);
                    if(jd==sb2.getMax()){
                       sb3.setVisibility(View.INVISIBLE);//不显示位置保留
                    }
                    else {
                        sb3.setVisibility(View.VISIBLE);
                    }
    
                }
    
                @Override
                    public void onStartTrackingTouch(SeekBar seekBar) {
                    Log.e("TAG","进度条开始拖动了");
    
                }
    
                @Override
                public void onStopTrackingTouch(SeekBar seekBar) {
                    Log.e("TAG","进度条停止拖动了");
                }
            });
    
    
        }
    }

    java代码

  • 相关阅读:
    Python迭代器的反复使用
    快速求幂模运算实现
    rural lifestyle & city lifestyle
    Python实现 扩展的欧几里德算法求(模逆数)最大公约数
    jupyter themes一行命令设置个人最爱界面
    python数组、矩阵相乘的多种方式
    有一组整型数,其中除了2个数字以外的其它数字都是俩俩成对出现的,编写程序找出这2个不成对出现的数字。
    Linux线程池技术处理多任务
    编写函数求两个整数 a 和 b 之间的较大值。要求不能使用if, while, switch, for, ?: 以 及任何的比较语句。
    C++const类型的引用参数
  • 原文地址:https://www.cnblogs.com/storm47/p/5480551.html
Copyright © 2011-2022 走看看