B4A Library CircularImageView

This library implement a Circular ImageView.
This is extremely similar to the normal imageview, except for one method (SetDrawable).
Use the SetDrawable method to set the foreground image, this makes use of the Circular style.
If you use SetBackground or SetBackgroundImage, it will revert to a square imageview.

License:
- Consider donating a litre of fuel if you use it in your non-profit apps.
- Consider donating more if you use it in a commercial app.
The only enforcement of this license is by your conscience.


Link to demo apk: http://www.b4x.com/android/forum/threads/demo-circularimageview-and-viewanimator.43254/
 

Attachments

  • CircularImageView.zip
    7 KB · Views: 805
  • Screenshot_2014-07-26-13-54-13.png
    Screenshot_2014-07-26-13-54-13.png
    109.8 KB · Views: 769
Last edited:

thedesolatesoul

Expert
Licensed User
Longtime User
MSCircularImageView
Author:
thedesolatesoul
Version: 0.51
  • CircularImageView
    Methods:
    • AddDefaultShadow
      Adds a dark shadow to this CircularImageView.
    • AddShadowLayer (radius As Float, dx As Float, dy As Float, color As Int)
      Sets the shadow layer parameters
      Max radius = 4, otherwise cuts out
      radius,: dx, dy, color
    • BringToFront
    • Initialize (arg1 As String)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • Refresh
      Refresh the CircularImageView
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetDrawable (d As BitmapDrawable)
      Set up the drawable to display
      Bitmap: drawable
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • isSelected As Boolean
      Returns whether or not this view is currently
      in its selected state.
      Only applicable when a Click event is defined, otherwise default to unselectable
    Properties:
    • Background As Drawable
    • BorderColor As Int [write only]
      Sets the CircularImageView's basic border color.
    • BorderWidth As Int [write only]
      Sets the CircuilarImageViews border width
    • Color As Int [write only]
    • Enabled As Boolean
    • Height As Int
    • Left As Int
    • SelectorColor As Int [write only]
      Sets the color of the selector to be draw over the
      CircularImageView. Be sure to provide some opacity.
    • SelectorStrokeColor As Int [write only]
      Sets the stroke color to be drawn around the CircularImageView
      during click events when the selector is enabled.
    • SelectorStrokeWidth As Int [write only]
      Sets the stroke width to be drawn around the CircularImageView
      during click events when the selector is enabled.
    • Tag As Object
    • Top As Int
    • Visible As Boolean
    • Width As Int
 

bluedude

Well-Known Member
Licensed User
Longtime User
Something like this would be very useful in combination with a panel and camera library :) A round camera panel would be interesting.
 

susu

Well-Known Member
Licensed User
Longtime User
How can I handle Click event on CircularImageView?
 

thedesolatesoul

Expert
Licensed User
Longtime User
Can you put a simple sample to use?

The Image appear in a square view in this sample

civ.Initialize("civ")
civ.Color = Colors.Red
civ.BorderWidth = 5dip
civ.BorderColor = Colors.blue
civ.SetBackgroundImage(LoadBitmap(File.DirAssets,"Koala.jpg") )
civ.AddDefaultShadow
civ.Activity.AddView( civ,0,0,50,50)
Please read the first four lines for the first post again.
 

Alberto Iglesias

Well-Known Member
Licensed User
Longtime User
I see..

and then a simple snippet for other users to become easier life.


Dim civ As CircularImageView
civ.Initialize("civ")
civ.Color = Colors.Transparent
civ.BorderWidth = 2dip
civ.BorderColor = Colors.blue

Dim imgBack As BitmapDrawable
imgBack.Initialize( LoadBitmap(File.DirAssets,"Koala.jpg"))

civ.SetDrawable ( imgBack )

Activity.AddView( civ,0,0,50,50)
 

Kwame Twum

Active Member
Licensed User
Longtime User
Hi,
I tried using the Lib in an app and I keep getting "Invalidated Drawable in the logs and app closes. Here's how I used it:

B4X:
Dim imm As CircularImageView
imm.Initialize("imm")
imm.Color = Colors.Transparent
imm.BorderWidth = 2dip
Dim bm as bitmap
bm.InitializeSample(File.DirAssets,"ddp.jpg",70dip,70dip)
Dim bim As BitmapDrawable
bim.Initialize(bm)
imm.SetDrawable(bim)

I also noticed the following in the logs:
B4X:
java.lang.RuntimeException: Object should first be initialized (CircularImageView).
 

Kwame Twum

Active Member
Licensed User
Longtime User
It has stopped giving the "Object should first be initialized (CircularImageView)." error...
It just gives me five lines of "Invalidated Drawable" in the logs, nothing more...
 

Kwame Twum

Active Member
Licensed User
Longtime User
Works now!!!! seems to only work on a real device
I made no changes to the code...

Still shows the "Invalidated Drawable" in the Logs though.
 
Top