Skip to content

Commit a7a16f8

Browse files
committed
Figures how to override theme for widgets.
Thanks to http://stackoverflow.com/a/26715076/172690.
1 parent a162b1e commit a7a16f8

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

app/src/main/res/layout/activity_main.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
22
xmlns:tools="http://schemas.android.com/tools"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
34
android:orientation="vertical"
45
android:layout_width="match_parent"
56
android:layout_height="match_parent"
@@ -35,6 +36,7 @@
3536
</android.support.design.widget.TextInputLayout>
3637

3738
<android.support.design.widget.TextInputLayout
39+
app:theme="@style/override_theme"
3840
android:layout_width="fill_parent"
3941
android:layout_height="wrap_content">
4042

@@ -47,6 +49,7 @@
4749
</android.support.design.widget.TextInputLayout>
4850

4951
<android.support.design.widget.TextInputLayout
52+
app:theme="@style/override_theme"
5053
android:layout_width="fill_parent"
5154
android:layout_height="wrap_content">
5255

app/src/main/res/values/styles.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@
55
<!-- Customize your theme here. -->
66
<item name="colorPrimary">#2196F3</item>
77
<item name="colorPrimaryDark">#1565C0</item>
8-
<item name="colorAccent">#E91E63</item>
8+
<item name="colorAccent">#ffbE63</item>
9+
</style>
10+
11+
<style name="override_theme" parent="AppTheme">
12+
<item name="colorPrimary">#FF0000</item>
13+
<item name="colorPrimaryDark">#00FF00</item>
14+
<item name="colorAccent">#00FFFF</item>
915
</style>
1016

1117
</resources>

0 commit comments

Comments
 (0)