Custom circular scrollbar (transparency effect)--take advantage of open source project Progresswheel

Source: Internet
Author: User

The Open source project Progresswheel provides us with a wide variety of circular scrollbars, which this article leads readers to use to implement custom scroll bars. In the official demo, a screen shows several styles, and this article only describes one style, that is, centered display, transparent layout. And with static encapsulation, both start and close require a single line of code to complete.

    1. Open Source Project Progresswheel address:
      Https://github.com/Todd-Davies/ProgressWheel

    2. Open Source Project Progresswheel:

    3. The implementation of a custom scrollbar (transparency effect):

      1). xml:
<?xml version="1.0"encoding="Utf-8"? ><linearlayout xmlns:android="Http://schemas.android.com/apk/res/android"Xmlns:progresswheel="Http://schemas.android.com/apk/res-auto"Android:id="@+id/layout_progress_wheel"Android:layout_width="Fill_parent"android:layout_height="Match_parent"android:layout_gravity="Center"android:orientation="Vertical"> <com.todddavies.components.progressbar.progresswheel android:id="@+id/pw_spinner"Android:layout_width="100DP"android:layout_height="100DP"android:layout_gravity="Center"Progresswheel:barcolor="#0097D6"Progresswheel:barlength="100DP"Progresswheel:barwidth="5DP"Progresswheel:rimcolor="#330097D6"Progresswheel:rimwidth="10DP"progresswheel:text="Loading ..."Progresswheel:textcolor="#222"Progresswheel:contourcolor="#330097D6"Progresswheel:textsize="14SP"/></linearlayout>
2). Style:
  <style name="Dialog" parent="android:style/Theme.Dialog">        <item name="android:background">#00000000</item>        <item name="android:windowBackground">@android:color/transparent</item>        <item name="android:windowNoTitle">true</item>        <item name="android:windowIsFloating">true</item>    </style>
3). Java Code:
    Public  class loadingcommentdialog {    Private StaticDialog Mdialog =NULL;Private StaticProgresswheel Mprogresswheel =NULL; Public Static void Showcommentdialog(Context context, String text)        {Closecommentdialog (context);        WindowManager m = (Activity) context). Getwindowmanager (); Display d = m.getdefaultdisplay ();//Get screen width, high-useMdialog =NewDialog (context, r.style.dialog);        Layoutinflater Inflater = (Activity) context). Getlayoutinflater (); View layout = Inflater.inflate (R.layout.layout_progress_wheel,NULL);        Mdialog.setcontentview (layout);        Mprogresswheel = (progresswheel) Layout.findviewbyid (R.id.pw_spinner);        Mprogresswheel.settext (text); Window Dialogwindow = Mdialog.getwindow ();//Windowmanager.layoutparams LP = Dialogwindow.getattributes (); lp.gravity = Gravity.center;//lp.x = 20;//new position X coordinate        //lp.y = 60;//new position y-coordinateLp.width = D.getwidth ()- -;//Width        //lp.height = (int) (D.getheight () *0.4);//HeightDialogwindow.setattributes (LP);        Mprogresswheel.spin ();    Mdialog.show (); } Public Static void Closecommentdialog(Context context) {if(mprogresswheel!=NULL) {mprogresswheel.stopspinning (); Mprogresswheel =NULL; }if(mdialog!=NULL) {Mdialog.dismiss (); Mdialog =NULL; }    }}
4). Call Method:
//这里可以自定义圆形中的文字。//YourFouction() //这里,是开始你的线程,或者异步请求,或者耗时的操作...关闭:LoadingCommentDialog.closeCommentDialog(mContext);

Finally, attach the custom scroll bar (transparency effect):

The power of open source is endless!

Custom circular scrollbar (transparency effect)--take advantage of open source project Progresswheel

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.