Try using a third constructor that takes an attr resource:
addView(Button(activity, null, R.attr.borderlessButtonStyle))
Alternatively, you can declare it as a component of DSL:
fun ViewManager.borderlessButton(textRes: Int = 0) = borderlessButton(textRes) { } fun ViewManager.borderlessButton(textRes: Int = 0, init: Button.()->Unit) = ankoView({ Button(it, null, R.attr.borderlessButtonStyle) }, 0) { if (textRes != 0) setText(textRes) init() }
Then your site might look like this:
borderlessButton(android.R.string.ok)
You can look at the Anko horizontalProgressBar and HORIZONTAL_PROGRESS_BAR_FACRTORY methods, which are declared in the same way.
source share