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代码

  • 相关阅读:
    vue 项目界面绘制_stylus_iconfont_swiper
    react_结合 redux
    BOM 浏览器对象模型_当前窗口的浏览历史 history 对象
    BOM 浏览器对象模型_Storage 接口
    react_app 项目开发 (9)_数据可视化 ECharts
    react_app 项目开发 (8)_角色管理_用户管理----权限管理 ---- shouldComponentUpdate
    BOM 浏览器对象模型_同源限制
    面试题: 多个 await 处理,有一个失败,就算作失败
    react_app 项目开发 (7)_难点集合
    react_app 项目开发_遇到的坑
  • 原文地址:https://www.cnblogs.com/storm47/p/5480551.html
Copyright © 2011-2022 走看看