Kotlin / anko

Pleasant Android application development
Apache License 2.0
15.91k stars 1.28k forks source link

Material Design Components? #724

Open bartekpacia opened 5 years ago

bartekpacia commented 5 years ago

Are there plans to add these to Anko? It isn't possible insets on Buttons, strokeColor on CardView etc.

ageevvalentin commented 5 years ago

I added example to wiki (https://github.com/Kotlin/anko/wiki/Anko-Layouts-Examples#styles). Try

<style name="App.ThemeOverlay.MaterialComponents.Button.Custom"
parent="ThemeOverlay.MaterialComponents">
        <item name="materialButtonStyle">
            @style/Widget.MaterialComponents.Button.TextButton.Custom
        </item>
</style>

<style name="App.MaterialComponents.TextButton.Custom"
parent="Widget.MaterialComponents.Button.TextButton">
        <item name="android:insetTop">8dp</item>
</style>
inline fun ViewManager.materialButton(@StyleRes theme: Int, init: MaterialButton.() -> Unit = {}): MaterialButton {
    return ankoView({ MaterialButton(it) }, theme, init = init)
}

Using:

materialButton(R.style.App_ThemeOverlay_MaterialComponents_Button_Custom)