How to define letterSpace dp in the Kotlin code (programmatically)?

121 views Asked by At

I have a material customButton and I want to give it a letterSpace in the code part.

The letterSpace value is = 0.38dp.

I have tried this but this is not gives the result that I want:

class KycButton : MaterialButton {
    constructor(context: Context?) : super(context!!)
    constructor(context: Context?, attrs: AttributeSet?) : super(context!!, attrs)
    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
        context!!,
        attrs,
        defStyleAttr
    )

    init {
        setBackgroundResource(R.drawable.kyc_button)
        isAllCaps = false
        textSize = 15f
        typeface = ResourcesCompat.getFont(context, R.font.montserrat_semibold)
        letterSpacing = 0.38f
        this.stateListAnimator = null
    }
}

How can I set its actual 'dp' value in this code piece?

0

There are 0 answers