文本颜色和元素颜色在oreo中更改

时间:2017-11-03 12:57:19

标签: android android-8.0-oreo

DatePickerDialog的文本颜色在oreo(谷歌像素)设备中变为白色,如下图所示,这在pre-oreo设备中看起来很完美。

enter image description here

抽屉菜单字体也会变成白色,如下图所示,这在预先设备中看起来也很完美。

enter image description here

禁用切换颜色变为白色,如下图所示

enter image description here

在我的gradle文件中:

compileSdkVersion 26
buildToolsVersion "26.0.2"
targetSdkVersion 26

compile 'com.android.support:design:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'

Style.xml:

        

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/newcolorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:windowBackground">@color/window_background</item>
    <item name="android:actionButtonStyle">@style/ActionButtonStyle</item>
    <item name="colorControlNormal">@color/white</item>
    <item name="actionMenuTextColor">@color/white</item>
    <item name="android:actionMenuTextColor">@color/white</item>

    <!-- Active thumb color & Active track color(30% transparency) -->
    <item name="colorControlActivated">@color/colorAccent</item>
    <!-- Inactive thumb color -->
    <item name="colorSwitchThumbNormal">@color/white</item>
    <!-- Inactive track color(30% transparency) -->
    <item name="android:colorForeground">@color/white</item>
</style>

<style name="AppDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
    <item name="windowNoTitle">true</item>
    <item name="android:background">@color/transparent</item> //Your custom background color
</style>

<!--this will reduce space between actionBar Icons-->
<style name="ActionButtonStyle" parent="Widget.AppCompat.ActionButton">
    <item name="android:paddingLeft">5dip</item>
    <item name="android:paddingRight">5dip</item>
</style>

<style name="StarRatingBar" parent="@android:style/Widget.RatingBar">
    <item name="android:progressDrawable">@drawable/bg_rating_bar</item>
    <item name="android:numStars">5</item>
</style>

<style name="Base.Widget.Design.TabLayout" parent="android:Widget">
    <item name="tabBackground">@drawable/tab_bar_selector</item>
    <!--<item name="tabIndicatorColor">@color/white</item>
    <item name="tabIndicatorHeight">4dp</item>-->
</style>

<style name="Widget.CardContent" parent="android:Widget">
    <item name="android:paddingLeft">16dp</item>
    <item name="android:paddingRight">16dp</item>
    <item name="android:paddingTop">24dp</item>
    <item name="android:paddingBottom">24dp</item>
    <item name="android:orientation">vertical</item>
</style>

<style name="MenuLabelsStyle">
    <item name="android:background">@drawable/fab_label_background</item>
    <item name="android:textColor">#FFFFFF</item>
    <item name="android:textSize">14sp</item>
    <item name="android:maxLines">2</item>
    <item name="android:ellipsize">end</item>
</style>

<style name="MenuButtonsStyle">
    <item name="fab_size">normal</item>
    <item name="fab_showAnimation">@anim/jump_from_down</item>
    <item name="fab_hideAnimation">@anim/jump_to_down</item>
    <item name="fab_shadowColor">#444</item>
    <item name="fab_colorNormal">?attr/colorPrimaryDark</item>
    <item name="fab_colorPressed">?attr/colorPrimary</item>
    <item name="fab_colorRipple">?attr/rippleColor</item>
</style>

<style name="MenuButtonsSmall">
    <item name="fab_size">mini</item>
    <item name="fab_colorNormal">#1565C0</item>
    <item name="fab_colorPressed">#2272CD</item>
    <item name="fab_colorRipple">#62B2FF</item>
</style>

<style name="MenuButtonsSmall.Green">
    <item name="fab_colorNormal">#43A047</item>
    <item name="fab_colorPressed">#2E7D32</item>
    <item name="fab_colorRipple">#1B5E20</item>
</style>

<style name="MenuButtonsSmall.AppColor">
    <item name="fab_colorNormal">@color/colorPrimaryTrans</item>
    <item name="fab_colorPressed">@color/colorPrimaryDarkTrans</item>
    <item name="fab_colorRipple">@color/colorAccentTrans</item>
    <item name="fab_size">normal</item>
</style>

<style name="FavTextInput1" parent="TextAppearance.AppCompat">
    <!-- Hint color and label color in FALSE state -->
    <item name="android:textColorHint">@color/gray_9ea</item>
    <item name="android:textSize">20sp</item>
    <!-- Label color in TRUE state and bar color FALSE and TRUE State -->
    <item name="colorAccent">@color/colorAccent</item>
    <item name="colorControlNormal">@color/gray_9ea</item>
    <item name="colorControlActivated">@color/colorAccent</item>
</style>
<style name="FavTextInput2" parent="TextAppearance.AppCompat">
    <!-- Hint color and label color in FALSE state -->
    <item name="android:textColorHint">@color/gray_9ea</item>
    <item name="android:textSize">14sp</item>
    <!-- Label color in TRUE state and bar color FALSE and TRUE State -->
    <item name="colorAccent">@color/colorAccent</item>
    <item name="colorControlNormal">@color/gray_9ea</item>
    <item name="colorControlActivated">@color/colorAccent</item>
</style>

<style name="TextLabel" parent="Widget.Design.TextInputLayout">
    <item name="android:textColorHint">@color/white_lite</item>
</style>

<style name="TextError" parent="Widget.Design.TextInputLayout">
    <item name="android:textColor">@color/white_lite</item>
</style>

<style name="Color1SwitchStyle" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorControlActivated">@color/colorAccent</item>
    <item name="colorSwitchThumbNormal">@color/light_gray</item>
    <item name="android:colorForeground">@color/dark_gray</item>
</style>

<style name="AlertDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
    <item name="android:textColorPrimaryInverse">@color/black</item>
</style>

<style name="MyDatePicker" parent="android:Widget.Material.Light.DatePicker">
    <item name="android:textColorPrimary">@color/black</item>

</style> </resources>

如果有更多信息需要,请告诉我。 提前谢谢。

1 个答案:

答案 0 :(得分:1)

检查你的res / Values / Styles.xml

https://developer.android.com/training/material/theme.html

你应该接近的是:

  1. 样式父母

  2. 使用:“textColorSecondary”,“textColor”