When I use Android: progressDrawable =" @ drawable / barcolor ", it works properly, but when I Use setProgressDrawable, it looks wrong My Layout: and my Java code: and barco Lor.xml: Thank you all!
& lt; XML version = "1.0" encoding = "utf-8" & gt; & Lt; RelativeLayout xmlns: android = "Http://schemaskandroidkcom/apk/res/android" android: orientation = "vertical" android: Layout_width = "Fill_parent" Android: layout_height = "fill_parent" & gt; & Lt; ProgressBar Android "Android: attr / progressBarStyleHorizontal" id = "@ + id / firstProgressBar" style = Android: layout_width = "300dip" Android: layout_height = "30dip" Android: layout_centerHorizontal = "true" Android: layout_above = "@ + id / Text_first "Android: Max =" 300 "Android: Progress =" 0 "/> Android: Android: Layout_height = "Wrap_content" Android: Layout_alignParentBottom = "True" Android: Layout_marginBottom = "L0dp" Android: Android: Left_margin = "android: gravity =" center "/ & gt; & Lt; / RelativeLayout & gt; < / code>
Prthampradrshnbar = (progressbar) Khojwubiaiaidi (RID 4); Resid = getResources () getIdentifier ( "barcolor", "drawable" , PackageName). Rectangle border = taking first progress. progressive (). GetBounds (); firstProgressBar.setProgressDrawable (. getResources () getDrawable (Resid)); firstProgressBar.getProgressDrawable () setBounds (limit).
& lt ;? xml version = "1.0" encoding = "UTF-8"? & Gt; LayerList xmlns: android = "http: // schemas.android.com/apk/res/android "& gt; & Lt; before android: id =" @ android: id / background "& gt; & Lt; nine patch Android: src =" @ drawable / Prgti_bar_bg "& Gt; & lt; / nine patch & gt; & lt; / item & gt; item android: id = "@ android: id / progress" & gt; & Lt; Clip & gt; & Lt; Nine patch Android: src = "@drawable / progress_bar" & gt; & Lt; / Nine patch & gt; & Lt; / Clips & gt; & Lt; / Item & gt; & Lt; / Layer-list & gt;
Sunday, 15 February 2015
android ProgressBar setProgressDrawable is not working properly -
Try it:
Be the first program. ViewTreeObserver (). AddOnGlobalLayoutListener (New ViewTreeObserver.OnGlobalLayoutListener () {@Override Global Layouts on Public Zero (Rectangle Segment = First Display Bar.GetprogressDearable). GetBounds (); Drawable Drawable = getResources (builder); Drawable.Setbound (front); First display bar .capturable (drawable); if (build.VERSION.SDK_INT> = Build.VERSION_CODES.JELLY_BEAN) {first program burgate.Witry Observer (). ExtractOnLealLabeloutOutator (this);} Other {Firstprogressbar.getViewTreeObserver (). RemoveGlobalOnLayoutListener (this); }}});
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment