问题
I am currently using this custom styles layout for my EditTexts
defined in 'styles.xml':
<style name="Form_EditView">
<item name="android:textColor">@color/white</item>
<item name="android:textSize">@dimen/large_text_size</item>
<item name="colorControlNormal">@color/white</item>
<item name="colorControlActivated">@color/pink</item>
<item name="colorControlHighlight">@color/pink</item>
</style>
However now my dilemma occurs as I have a TextView
that I would like to be styled like a default Android EditText but then to also apply my above custom styling. The default Android style is the one displayed below:
style="@android:style/Widget.EditText"
I know that inheritance is possible in layout styles files but how do I go about inheriting from Android default styles in my custom styles, to achieve something similar to this:
<style name="Widget.EditText.Form_EditView">
回答1:
The simplest way to inherit some other style - is to use parent
attribute:
<style name="Form_EditView" parent="@android:style/Widget.EditText">
As @Bobby StJacques pointed out, if you want to inherit styles you defined (not built-in Android ones), you can use the following form:
<style name="Form_EditView.SomeCustomizedEditView">
....
</style>
In this case you inherit your already defined Form_EditView
来源:https://stackoverflow.com/questions/34004674/how-do-i-inherit-from-default-android-style-in-my-custom-styles-xml