One, the custom progress bar
1.<progressbar android:id= "@+id/patch_progress" style= "@style/gxprogressstyle" android:layout_width= "Match_parent" android:layout_height = "12DP" android:layout_alignparentbottom= "true" android:layout_centerhorizontal= "true" android:gravity= "center" />2.style.xml introduced in: <style name= "Gxprogressstyle" parent= "@android: style/ Widget.ProgressBar.Horizontal "> <item name=" Android: Progressdrawable "> @drawable/progressbarcolor</item> </style> 3. progressbarcolor.xml: <layer-list xmlns:android= " Http://schemas.android.com/apk/res/anDroid " > <item android:id=" @android: Id/background "> <shape> <corners android:radius= "5dip" /> <gradient " android:angle=" android:centercolor= "#1B5E9D" android:centery= "0.75" android:endcolor= "#156096" android:startcolor= "#156096" / > &nBsp; </shape> </item> <item android:id= "@android: Id/progress" > <clip> <shape> <corners android:radius= "5dip" /> < gradient " android:angle=" android:centercolor= "#2CC2DB" android:endcolor= "# 13a3c8 "&NBSP;&NBSP;&NBSP;&NBsp; android: Startcolor= "#63F8FB" /> </ Shape> </clip> </item> </layer-list>
Second, text stroke style:
package com.ddianle.autoupdate;import com.ddianle.lovedance.commonlibrary.r;import Android.content.context;import android.graphics.canvas;import android.graphics.paint.style;import android.text.textpaint;import android.util.attributeset;import android.view.viewgroup;import android.widget.TextView;/** * text with white strokes textview * */public class stroketextview extends textview {private textview bordertext = null;// /Textviewpublic stroketextview (Context context) {super (Context) for the stroke; bordertext = new textview (context); init ();} Public stroketextview (context context, attributeset attrs) {super (context, attrs ); Bordertext = new textview (context, attrs); init ();} Public stroketextview (Context context, attributeset attrs, int defstyle) { Super (Context, attrs, defstyle); bOrdertext = new textview (Context, attrs, defstyle); init ();} Public void init () {textpaint tp1 = bordertext.getpaint (); Tp1.setStrokeWidth (5); // Set Stroke width tp1.setstyle (style.stroke); // only stroke the text Bordertext.settextcolor (Getresources (). GetColor (r.color.white)); // Set stroke color bordertext.setgravity (getgravity ());} @Overridepublic void setlayoutparams (viewgroup.layoutparams params) {super.setlayoutparams (params); Bordertext.setlayoutparams (params);} @Overrideprotected void onmeasure (Int widthmeasurespec, int heightmeasurespec) { Charsequence tt = bordertext.gettext ();// the text on the two textview must be consistent if (tt == null | | !tt.equals (This.gettext ())) {bordertext.settext (GetText ()); This.postinvalidate ();} Super.onmeasure (Widthmeasurespec, heightmeasurespec); Bordertext.measure (widthmeasurespec, HEIGHTMEASURESPEC);} Protected void&nbsP;onlayout (boolean changed, int left, int top, int right, int Bottom) {super.onlayout (Changed, left, top, right, bottom); Bordertext.layout (left, top, right, bottom);} @Overrideprotected void ondraw (Canvas canvas) {bordertext.draw (canvas); Super.ondraw (canvas );}}
Three, the text up and down scrolling textswithcher application
<textswitcher android:id= "@+id/ts_tip" android:layout_width= "Wrap_content" android:layout_height= "Wrap_content" android:layout_ Alignparentbottom= "true" android:layout_centerhorizontal= "true" ></TextSwitcher> Set 5s scrolling once: mtipshandler.sendemptymessagedelayed (0, 5000);p rivate Handler mtipshandler = new handler () { @Override public void handlemessage (message msg) {super.handlemessage (msg);if (tips == null) { return;} if (Tipsindex >= tips.length) { tipsindex = 0;} Tipsanimation (Tstip, tips[tipsindex]); tipsindex++;mtipshandler.sendemptymessagedelayEd (0, tips_delayed); }};//in order to achieve the stroke effect, with two textswitcher to achieve textswitchersetting (ts1,true); Textswitchersetting (ts2,false);// set Textswither,boolean to determine whether to add stroke private void textswitchersetting ( Textswitcher ts, final boolean isstroke) { ts.setfactory (new viewfactory () { @Override public View Makeview () {textview tv = new textview (context, null);if (IsStroke) { textpaint paint = tv.getpaint (); Paint.setstrokewidth (n); paint.setstyle (Style.stroke);} Tv.settextsize, Tv.setgravity (gravity.center);if (Isstroke) { Tv.settextcolor (Context.getresources (). GetColor (R.color.black));} else { tv.settextcolor (Context.getresources (). GetColor (R.color.white));} return tv; }); Tipsanimation (Ts, context.getstring (Resourceutil.getstringid (context, ) Ddl_tips_loading ")));} textswitcher animation private void tipsanimation (TEXTSWITCHER&NBSP;TS,&NBSP;STRING&NBSP;STR) { Ts.settext (str);// set the cut-in animation ts.setinanimation (Animationutils.loadanimation (context, r.anim.move_in));// Set the cut-out animation ts.setoutanimation (Animationutils.loadanimation (Context, r.anim.move_out));}
Custom progress bar \ text Stroke style \ Text up and down scrolling textswithcher app