• 用SeekBar控制图片的透明度 控制SeekBar进度条来同时触发ProgressBar


    <?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.hanqi.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:max="80"
            android:secondaryProgress="0"
            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:src="@drawable/xiao3"
            android:alpha="1"
            android:id="@+id/iv_1"/>
    
        <SeekBar
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:progress="0"
            android:secondaryProgress="0"
            android:max="200"
            android:id="@+id/se_2"/>
    
    </LinearLayout>
    package com.hanqi.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;
        SeekBar se_2;
        ImageView iv_1;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_test4);
    
            se_1=(SeekBar)findViewById(R.id.se_1);
            pb_1=(ProgressBar)findViewById(R.id.pb_1);
            pb_2=(ProgressBar)findViewById(R.id.pb_2);
            se_2=(SeekBar)findViewById(R.id.se_2);
            iv_1=(ImageView)findViewById(R.id.iv_1);
            iv_1.setAlpha(0);
    
           // AlertDialog ad=new AlertDialog.Builder(this).create();
    
            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","进度条停止拖动");
                }
            });
    
            se_2.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
    
                @Override
                public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
    
                iv_1.setAlpha(progress);
    
                }
    
                @Override
                public void onStartTrackingTouch(SeekBar seekBar) {
    
                    Log.e("TAG","进度条开始拖动");
    
                }
    
                @Override
                public void onStopTrackingTouch(SeekBar seekBar) {
    
                    Log.e("TAG","进度条停止拖动");
    
                }
            });
        }
    }

           

  • 相关阅读:
    linux设备模型
    dma
    POSIX thread
    Network: IP QoS
    TCP: sliding window of flow control
    TCPIP: UDP/TCP checksum
    Hebrew: Learning Resources
    Vivado: Uninstall Vivado on ubuntu/linux
    HLS: vivado_hls compile fail, csim and csyn error, no ip generated for udpLoopback and toe
    HLS: High-Level Synthesis Operators
  • 原文地址:https://www.cnblogs.com/cycanfly/p/5479495.html
Copyright © 2020-2023  润新知