Android Question corner radius property to custom view

Kiran Raotole

Active Member
Licensed User
I want to give radius property to my custom view panel.

I'm try Base.CornerRadius

but it not cornerradius property in drop list.
 
Use ColorDrawable and set background.
 
Upvote 0
I don't know if there is another simple way to do this. Just get current panel color and set background with that color.
 
Upvote 0
Ok, but I'm unable to design CornerRadius property to panel.
No problem, here's example.

Code: Copy
'Custom View class
#DesignerProperty: Key: CornerRadius, DisplayName: Corner Radius, FieldType: Int, DefaultValue: 0, Description: Corner Radius
Sub Class_Globals
    Private mEventName As String 'ignore
    Private mCallBack As Object 'ignore
    Private mBase As Panel
    Private Const DefaultColorConstant As Int = -984833 'ignore
End Sub

Public Sub Initialize (Callback As Object, EventName As String)
    mEventName = EventName
    mCallBack = Callback
End Sub

Public Sub DesignerCreateView (Base As Panel, Lbl As Label, Props As Map)
    mBase = Base
    CornerRadius(Props.Get("CornerRadius"))
End Sub

Public Sub GetBase As Panel
    Return mBase
End Sub

Public Sub CornerRadius (Radius As Int)
    Dim cd As ColorDrawable
    Dim cvs As Canvas
    cvs.Initialize(mBase)   
    cd.Initialize(cvs.Bitmap.GetPixel(mBase.Width / 2,mBase.Height / 2),Radius)
    mBase.Background = cd
End Sub
 
Upvote 0
Back
Top