android - Draw Border on HorizontalScrollView Programmatically -


I'm trying to attract a border on the horizontal scroll view program, and fill in with a different color. I have tried different aproaches without success, I can attract only one thing at a time ... here I have tried the last code.

  Private Zero applyViewBorder (see layout, string border color, string fill collar, int border width) {if (Fillcolor == faucet = boundary color == empty) return; RectSpeed ​​Rect = new RectSpep (); Size Drainable RectSpeed ​​Darebull = New Size Drainage (Rect); Color Paint = rectShapeDrawable.getPaint (); Paint.setStyle (Style.STROKE); Paint.setStrokeWidth (BorderWidth); paint.setColor (Color.parseColor (BorderColor)); If (android.os.build.VERSION.SDK_INT & lt; 16) {layout.setBackgroundDrawable (rectShapeDrawable); } And {layout.setBackground (rectShapeDrawable); } Paint.setStyle (Style.FILL); paint.setColor (Color.parseColor (fillColor)); If (android.os.build.VERSION.SDK_INT & lt; 16) {layout.setBackgroundDrawable (rectShapeDrawable); } And {layout.setBackground (rectShapeDrawable); }}   

I have already searched in stack overflow, with no success ... Thanks in advance :)

What you can try

XML is called border.xml as the project droplet folder below:

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Layer-list xmlns: android = "http://schemas.android.com/apk/res/android" & gt; & Lt; Items & gt; & Lt; Size Android: shape = "rectangle" & gt; & Lt; Solid Android: Color = "# FF 20000" /> & Lt; / Size & gt; & Lt; / Item & gt; & Lt; Item android: left = "5dp" Android: right = "5dp" android: top = "5dp" & gt; & Lt; Size Android: shape = "rectangle" & gt; & Lt; Solid Android: Color = "# 000000" /> & Lt; / Size & gt; & Lt; / Item & gt; & Lt; / Layer-list & gt;   

and

  yourshorizontalscrollview.setBackgroundDrawable (getResources (). GetDrawable (R.drawable.border));   

or use it: yourshorizontalscrollview.setBackground (getResources (). GetDrawable (R.drawable.border));

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -