I would like to define custom styles for some widgets from Android Support Design (e.g. AppBarLayout, TextInputLayout, FAB ...) and set these styles by default for my project, as I can do with EditText and other system widgets. For example:
<style name="Theme.MyApp" parent="Theme.AppCompat.Light.NoActionBar"> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="android:editTextStyle">@style/Theme.MyApp.EditText</item> </style> <style name="Theme.MyApp.EditText" parent="Widget.AppCompat.EditText"> <item name="android:textColor">@color/my_awsome_edittext_color</item> <item name="android:layout_height">wrap_content</item> </style>
My current problem is set to raise AppBarLayout elevation = "0dp" for a specific Activity that has its own theme. After figuring out the source code for the Android AppBarLayout support design, I found out that it has a theme called Widget.Design.AppBarLayout , so I did:
<style name="Theme.MyApp.AppBarLayout" parent="Widget.Design.AppBarLayout"> <item name="elevation">0dp</item> </style>
But I did not find an attribute to set it in my Theme.MyApp , for example android:editTextStyle . And this is true for TextInputLayout, FAB and so on. These widgets customize their themes directly from the resource:
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.AppBarLayout, R.style.Widget_Design_AppBarLayout);
So, there really is no way to define styles in this form? If not, are there any technical reasons not to provide this feature?
android themes android-textinputlayout androiddesignsupport android-appbarlayout
hugonardo
source share