我尝试在Android布局xml中继承样式。
现在看起来像这样:
layout.xml:
<RelativeLayout
android:id="@id/btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
style="@style/AppTheme.ButtonLayout">
<TextView
android:id="@id/btn_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/AppTheme.ButtonLayout.TextView" />
</RelativeLayout>
styles.xml:
<style name="AppTheme.ButtonLayout">
<item name="android:textViewStyle">@style/AppTheme.ButtonLayout.TextView</item>
</style>
<style name="AppTheme.ButtonLayout.TextView" parent="android:Widget.Holo.Light.TextView">
<item name="android:textColor">@android:color/white</item>
</style>
我希望从TextView中删除“style”属性,但它应该继承RelativeLayout的外观。这是可能的吗?
编辑:我希望此TextView仅在具有@style/AppTheme.ButtonLayout样式的RelativeLayout内具有此样式。当它在没有此样式的布局中时,它应该看起来像默认的Android TextView。