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","进度条结束拖动");
}
});
}
}