Android Code Snippet [B4X] [XUI] Create a round image

Status
Not open for further replies.

M.LAZ

Active Member
Licensed User
Longtime User
i used it with AppCompat in Left Layout
and i called the main layout
B4X:
Activity.LoadLayout("homeScreen")

and i put my imageView1 in the Left Layout with designer
then Left Layout loaded in a panel as we use in AppCompat.
B4X:
Dim lftMenu As Panel  
    lftMenu.Initialize("")
     sm.Menu.AddView(lftMenu, 0, 0, 100%x - offset, 100%y)
    lftMenu.LoadLayout("Left")

then i used this code to create round bitmap
B4X:
    Dim img As B4XBitmap = Xui.LoadBitmap(File.DirAssets, "ff.jpg")
    'ImageView1.SetBitmap(CreateRoundBitmap(img, ImageView1.Width))
   
    Dim xIV As B4XView = ImageView1
    xIV.SetBitmap(CreateRoundBitmap(img, xIV .Width))
 

astronald

Active Member
Licensed User
Longtime User
Hello good day ,
How i can implement this on Widget, this is a service don't work properly.
I try
B4X:
Dim img As B4XBitmap = Xui.LoadBitmap(File.DirAssets, "imgFace.jpg")
rv.SetImage("imgFace",CreateRoundBitmap(img, 50dip))
return this error
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.ref.Reference.get()' on a null object reference
Thanks.
 
Last edited:

beacon

Member
Licensed User
Longtime User
This works fine for me, thank you; but what I can't fathom is how to get a transparent background, so as to have my chosen picture sitting (ie. "floating") over the device wallpaper.

If I make Activity.Color = xui.Color_Green it shows green behind the rounded picture, as I would expect.

If I make Activity.Color = xui.Color_Transparent it shows dark grey behind the rounded picture, as I would not expect.

I have also tested with Activity.Color, ImageView1.Color and xview.Color each set to xui.Color_Transparent.

The end result is always an opaque dark grey background behind the rounded picture.

Is this just a feature of the clip process?
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…