Reputation: 905
I try to develop an app for API 8 but do not have any experience with styles.xml. For activities in the app I use Theme.Light. After playing with styles I got the error above. I've also checked other posts on this portal and I tried many suggestions but I could not get further. The styles.xml is below and hopefully someone will come with suggestions.
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
<!--
Theme customizations available in newer API levels can go in
res/values-vXX/styles.xml, while customizations related to
backward-compatibility can go here.
-->
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>
<style name="ContactLabelTextView">
<item name="layout_width">wrap_content</item>
<item name="layout_height">wrap_content</item>
<item name="layout_gravity">left|center_vertical</item>
<item name="layout_marginLeft">15dp</item>
<item name="layout_marginRight">5dp</item>
<item name="layout_marginTop">5dp</item>
<item name="clickable">false</item>
<item name="longClickable">false</item>
<item name="textSize">14sp</item>
<item name="textAppearance">?android:attr/textAppearanceMedium</item>
<item name="android:textColor">@android:color/black</item>
<item name="layout_marginBottom">5dp</item>
</style>
<style name="ContactMultiplineText" >
<item name="layout_width">match_parent</item>
<item name="layout_height">wrap_content</item>
<item name="layout_marginLeft">15dp</item>
</style>
Upvotes: 0
Views: 1317
Reputation: 905
After reading the post recommended by Alexander Zhak I have better understanding of styles. Therefore, I made some modifications to my styles.xml and it works. Those modifications are:
...
<style name="ContactLabelTextView" parent="@android:style/TextAppearance.Medium">
<item name="android:textSize">14sp</item>
<item name="android:textColor">@android:color/black</item>
<item name="android:longClickable">false</item>
<item name="android:clickable">false</item>
</style>
<style name="ContactLabelTextView.Layout">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_gravity">left|center_vertical</item>
<item name="android:layout_marginLeft">15dp</item>
<item name="android:layout_marginRight">5dp</item>
<item name="android:layout_marginTop">5dp</item>
<item name="android:layout_marginBottom">5dp</item>
</style>
<style name="ContactMultiplineText">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginLeft">15dp</item>
</style>
...
Upvotes: 1
Reputation: 26198
You need to have a parent style
to enable you to call the attributes of it.
sample:
<style name="ContactLabelTextView" parent="@android:style/TextAppearance.Medium">
The above code is used when you want your textView
as a Medium size text, you can still change it what ever size you want for your TextView
.
Upvotes: 0