我正在尝试更改我的textView的颜色,而不更改其所有其他功能。我创建了一个样式,该特定的textView遵循该样式,因此,不更改此textView的背景,我只是更改了样式的背景。但是,这没有什么不同。如果您告诉我原因,我将不胜感激。 XML文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/cardview_default_elevation"
xmlns:android="http://schemas.android.com/apk/res/android">
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="2dp"
card_view:cardUseCompatPadding="true">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/question_textview"
style="@style/QuizCardQuestion"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold" />
<Button
android:id="@+id/choice1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/QuizCardChoice.OddChoice"
android:background="@drawable/question_button"
android:onClick="addQuestionScorer"/>
<include layout="@layout/divider"/>
<Button
android:id="@+id/choice2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/QuizCardChoice.EvenChoice"
android:background="@drawable/question_button"
android:onClick="addQuestionScorer"/>
<include layout="@layout/divider"/>
<Button
android:id="@+id/choice3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/QuizCardChoice.OddChoice"
android:background="@drawable/question_button"
android:onClick="addQuestionScorer"/>
<include layout="@layout/divider"/>
<Button
android:id="@+id/choice4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/QuizCardChoice.EvenChoice"
android:background="@drawable/question_button"
android:onClick="addQuestionScorer"/>
</LinearLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
样式文件:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/cardTitle</item>
</style>
<style name="AppTheme.Dark" parent="AppTheme">
<item name="android:windowBackground">@color/darker_gray</item>
<item name="android:textColorPrimary">@android:color/white</item>
</style>
<style name="QuizCardQuestion">
<item name="android:background">#00d4ff</item>
<item name="android:textAppearance">@style/TextAppearance.AppCompat.Medium</item>
<item name="android:textColor">#2F80ED</item>
<item name="android:padding">@dimen/activity_horizontal_margin</item>
</style>
<style name="QuizCardChoice" parent="Widget.AppCompat.Button.Borderless">
<item name="android:gravity">left|start</item>
<item name="android:textAppearance">@style/TextAppearance.AppCompat.Medium</item>
<item name="android:padding">@dimen/activity_horizontal_margin</item>
</style>
<style name="QuizCardChoice.OddChoice" parent="QuizCardChoice">
<item name="android:background">@color/white</item>
</style>
<style name="QuizCardChoice.EvenChoice" parent="QuizCardChoice">
<item name="android:background">@color/white</item>
</style>
<style name="QuizChoiceDivider">
<item name="android:layout_marginLeft">@dimen/divider_margin</item>
<item name="android:layout_marginRight">@dimen/divider_margin</item>
<item name="android:background">@color/light_gray</item>
</style>
<style name="QuizPageFooter">
<item name="android:background">#FFFFFF</item>
<item name="android:padding">@dimen/activity_horizontal_margin</item>
</style>
<style name="CorrectAnswerBox" parent="QuizCardChoice">
<item name="android:background">@color/correctAnswerGreen</item>
</style>
<style name="WrongAnswerBox" parent="QuizCardChoice">
<item name="android:background">@color/wrongAnswerRed</item>
</style>
<style name="StatsTitles" parent="TextAppearance.AppCompat.Subhead">
<item name="android:textStyle">bold</item>
<item name="android:textColor">@color/dark_gray</item>
<item name="android:paddingBottom">@dimen/activity_vertical_margin</item>
</style>
<style name="FullStatistics" parent="StatsLabels">
</style>
<style name="StatsLabels" parent="TextAppearance.AppCompat.Medium">
<item name="android:textColor">@android:color/black</item>
</style>
<style name="StatsContent" parent="TextAppearance.AppCompat.SearchResult.Subtitle">
<item name="android:textColor">@color/dark_gray</item>
<item name="android:paddingBottom">@dimen/activity_vertical_margin</item>
</style>
<style name="WelcomeHeadings" parent="StatsLabels">
</style>
<style name="spinnerItemStyle" parent="android:Widget.TextView.SpinnerItem">
<item name="android:padding">0dp</item>
<item name="android:textAppearance">@style/StatsLabels</item>
<item name="android:textColor">@color/dark_gray</item>
</style>
<style name="spinnerDropDownItemStyle" parent="android:TextAppearance.Widget.TextView.SpinnerItem">
<item name="android:padding">@dimen/activity_vertical_margin</item>
<item name="android:textStyle">italic</item>
</style>
<style name="AppTheme.Launcher" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@drawable/splash_screen</item>
</style>
</resources>
错误图片:
(注意:紫色框应为蓝色)