I have a custom view written in Kotlin using JvmOverloads that I could have default value.
class MyView @JvmOverloads constructor(
context: Context,
attr
Best way is to have your class this way.
class MyView : LinearLayout {
@JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : super(context, attrs, defStyleAttr)
@TargetApi(Build.VERSION_CODES.LOLLIPOP) constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(context, attrs, defStyleAttr, defStyleRes)
}