Control the transparency of a picture with Seekbar

Source: Internet
Author: User

<?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>

 Packagecom.hanqi.testapp2;ImportAndroid.os.Bundle;Importandroid.support.v7.app.AppCompatActivity;ImportAndroid.util.Log;ImportAndroid.view.View;ImportAndroid.widget.ImageView;ImportAndroid.widget.ProgressBar;ImportAndroid.widget.SeekBar; Public classTestActivity4extendsappcompatactivity {SeekBar se_1;    ProgressBar pb_1;    ProgressBar pb_2;    SeekBar se_2;    ImageView iv_1; @Overrideprotected voidonCreate (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 (NewSeekbar.onseekbarchangelistener () {//Progress Change Trigger@Override Public voidOnprogresschanged (SeekBar SeekBar,intProgressBooleanFromuser) {                //set progress value for progress bar 1pb_1.setprogress (progress); //determine if the maximum value is reached                if(progress==Se_1.getmax ()) {pb_2.setvisibility (view.invisible);//not displayed but the location is still reserved                }                Else{pb_2.setvisibility (view.visible); }                //as long as the progress change is triggered .//Toast.maketext (Testactivity4.this, "current progress =" +progress, Toast.length_short). Show ();} @Override Public voidOnstarttrackingtouch (SeekBar SeekBar) {LOG.E ("TAG", "progress bar start dragging"); } @Override Public voidOnstoptrackingtouch (SeekBar SeekBar) {LOG.E ("TAG", "Progress bar Stop dragging");        }        }); Se_2.setonseekbarchangelistener (NewSeekbar.onseekbarchangelistener () {@Override Public voidOnprogresschanged (SeekBar SeekBar,intProgressBooleanFromuser)            {Iv_1.setalpha (progress); } @Override Public voidOnstarttrackingtouch (SeekBar SeekBar) {LOG.E ("TAG", "progress bar start dragging"); } @Override Public voidOnstoptrackingtouch (SeekBar SeekBar) {LOG.E ("TAG", "Progress bar Stop dragging");    }        }); }}

Control the transparency of a picture with Seekbar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.