Android Question corner radius property to custom view

Discussion in 'Android Questions' started by Kiran Raotole, Sep 1, 2018.

  1. Kiran Raotole

    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.
     
  2. npsonic

    npsonic Active Member Licensed User

    Use ColorDrawable and set background.
     
  3. Kiran Raotole

    Kiran Raotole Active Member Licensed User

    I dont want to set back ground color or something other, just cornerradius.
     
  4. npsonic

    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.
     
  5. Kiran Raotole

    Kiran Raotole Active Member Licensed User

    Ok, but I'm unable to design CornerRadius property to panel.
     
  6. npsonic

    npsonic Active Member Licensed User

    No problem, here's example.

    Code:
    '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
     
  7. Kiran Raotole

    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?
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice