In the given steps, we will learn how to set the theme for Android views using Anko:
- Let's start by first creating a style for a button. Custom styles are created in styles.xml inside the res/values/ directory. Let's create a button style and name it newButton. Add the following code in styles.xml:
<style name="newButton" parent="android:Widget.Holo.Light.Button"> <item name="android:colorButtonNormal">@color/colorAccent</item> <item name="android:textColor">@color/white</item></style>
- Now, let's use this style to create a themed button in our target activity. Let's keep our UI in another class using the AnkoComponent interface. The following is how we create a button with a custom theme in a DSL layout (focus on the bold ...