• 进度条


    package com.example.wang.testapp2;
    
    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 TestActivity4 extends AppCompatActivity {
    
        SeekBar se_1;
    
        ProgressBar pb_1;
        ProgressBar pb_2;
    
        ImageView iv_1;
        SeekBar se_2;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_test4);
    
            iv_1=(ImageView)findViewById(R.id.iv_1);
    
            iv_1.setAlpha(0f);
    
            se_2=(SeekBar)findViewById(R.id.se_2);
    
            se_2.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                @Override
                public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                    iv_1.setAlpha(progress/255.0f);
                }
    
                @Override
                public void onStartTrackingTouch(SeekBar seekBar) {
    
                }
    
                @Override
                public void onStopTrackingTouch(SeekBar seekBar) {
    
                }
            });
    
            pb_1=(ProgressBar)findViewById(R.id.pb_1);
            pb_2=(ProgressBar)findViewById(R.id.pb_2);
    
            se_1=(SeekBar)findViewById(R.id.se_1);
            se_1.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                @Override
                public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    
                    //设置进度条1的进度值
                    pb_1.setProgress(progress);
    
                    //判断是否达到最大值
                    if (progress==se_1.getMax())
                    {
                        pb_2.setVisibility(View.INVISIBLE);//不显示但位置还保留
                    }
                    else
                    {
                        pb_2.setVisibility(View.VISIBLE);
                    }
    
    
                    //只要progress变化就被触发
                   // Toast.makeText(TestActivity4.this, "当前进度="+progress, Toast.LENGTH_SHORT).show();
                }
    
                @Override
                public void onStartTrackingTouch(SeekBar seekBar) {
    
                    Log.e("TAG","进度条开始拖动");
    
                }
    
                @Override
                public void onStopTrackingTouch(SeekBar seekBar) {
                    Log.e("TAG","进度条结束拖动");
                }
            });
        }
    }
    View Code
    <?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:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context="com.example.wang.testapp2.TestActivity4"
        android:orientation="vertical">
        <ProgressBar
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            style="?android:attr/progressBarStyleHorizontal"
            android:progress="0"
            android:secondaryProgress="0"
            android:max="80"
            android:id="@+id/pb_1"/>
    
        <ProgressBar
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            style="?android:attr/progressBarStyleLarge"
            android:id="@+id/pb_2"/>
        <SeekBar
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:progress="0"
            android:secondaryProgress="0"
            android:max="80"
            android:id="@+id/se_1"/>
        <RatingBar
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:numStars="5"
            android:rating="3.5"
            android:isIndicator="true"/>
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="30dp"
            android:layout_marginBottom="30dp"
            android:src="@drawable/asd"
            android:layout_gravity="center"
            android:id="@+id/iv_1"/>
        <SeekBar
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/se_2"
            android:max="255"/>
    
    </LinearLayout>
    View Code

  • 相关阅读:
    python类的继承
    Numpy float64和Python float是一样的
    ndarray的用法总结
    pandas的Panel类型dtype
    C++中类的前向声明
    numpy的searchsorted细品
    发现Boost官方文档的一处错误(numpy的ndarray)
    C++读取dll文件所在目录
    64位的pyd报"ImportError: No module named"错误
    WIN32,_WIN32_WIN64
  • 原文地址:https://www.cnblogs.com/wangchuanqi/p/5491246.html
Copyright © 2020-2023  润新知