Android Learning-Interface-ui-seekbar

Source: Internet
Author: User

and Processbar almost, but his progress is can be dragged, directly see the effect

Activity_main.xml

<LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:id= "@+id/linearlayout1"Android:layout_width= "Fill_parent"Android:layout_height= "Fill_parent"android:orientation= "vertical"android:padding= "10DP" >    <TextViewAndroid:id= "@+id/textview1"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "Change Picture transparency"android:textappearance= "? Android:attr/textappearancelarge" />    <SeekBarAndroid:id= "@+id/seekbar1"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:max= "255"android:progress= "255"Android:thumb= "@drawable/ic_launcher"         />    <ImageViewAndroid:id= "@+id/imageview1"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"android:src= "@drawable/pic1" /></LinearLayout>
View Code

Mainactivity.java

 Public classMainactivityextendsactivity{SeekBar seekBar1;        ImageView ImageView1; Handler Handler=NewHandler () { Public voidhandlemessage (Message msg) {if(msg.what==123){                intAlpha =msg.getdata (). GETINT ("Alpha");            Imageview1.setimagealpha (Alpha);    }        }    }; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);                Setcontentview (R.layout.activity_main); ImageView1=(ImageView) Findviewbyid (R.ID.IMAGEVIEW1); SeekBar1=(SeekBar) Findviewbyid (R.ID.SEEKBAR1); Seekbar1.setonseekbarchangelistener (NewOnseekbarchangelistener () {@Override Public voidOnstoptrackingtouch (SeekBar SeekBar) {//TODO Auto-generated method stubs} @Override Public voidOnstarttrackingtouch (SeekBar SeekBar) {//TODO Auto-generated method stubs} @Override Public voidOnprogresschanged (SeekBar SeekBar,intProgress,BooleanFromuser) {Message msg=NewMessage (); Msg.what=123; Bundle Data=NewBundle (); Data.putint ("Alpha", progress);                Msg.setdata (data);                            Handler.sendmessage (msg);    }        }); }}
View Code

Android Learning-Interface-ui-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.