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.
 

npsonic

Active Member
Licensed User
Use ColorDrawable and set background.
 

npsonic

Active Member
Licensed User
I don't know if there is another simple way to do this. Just get current panel color and set background with that color.
 

npsonic

Active Member
Licensed User
Ok, but I'm unable to design CornerRadius property to panel.
No problem, here's example.

B4X:
'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
 

Kiran Raotole

Active Member
Licensed User
Hii Its work, thanks a lot.
and also I want to add key press animation like default button have.
Is you have any idea about that?
 
Top