Android Question image with Corner

Keith Yong

Active Member
Licensed User
Longtime User
I would like know how can I make the image with corner on top only, same like the image uploaded.

I manage to make the image with 4 corners and use a panel to cover at the bottom, but it doesn't looks good. May I know what is the best practice to have this to be done.
 

Attachments

  • corner.png
    corner.png
    48.7 KB · Views: 277

Erel

B4X founder
Staff member
Licensed User
Longtime User
Code to create image with 2 round corners:
Depends on XUI and BitmapCreator.
B4X:
Sub Globals
   Private ImageView1 As B4XView
   Private xui As XUI
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("1")
   Dim img As B4XBitmap = xui.LoadBitmapResize(File.DirAssets, "1.jpg.png", ImageView1.Width, ImageView1.Height, False)
   ImageWithTopCorners(img, ImageView1, 20dip)
End Sub

Sub ImageWithTopCorners (bmp As B4XBitmap, iv As B4XView, Radius As Int)
   Dim bc As BitmapCreator
   bc.Initialize(iv.Width, iv.Height)
   Dim brush As BCBrush = bc.CreateBrushFromBitmap(bmp)
   Dim rect As B4XRect
   rect.Initialize(0, 0, bc.mWidth - 1, bc.mHeight)
   bc.DrawRectRounded2(rect, brush, True, 0, Radius)
   rect.Initialize(0, bc.mHeight - Radius, bc.mWidth, bc.mHeight)
   bc.DrawRect2(rect, brush, True, 0)
   bc.SetBitmapToImageView(bc.Bitmap, iv)
End Sub

SS-2019-02-28_10.25.48.png
 
Upvote 0
Top