У меня есть следующий код:Атрибут tabTextAppearance не принимает шестнадцатеричный код цвета?
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.example.yazan.mylanguage.MainActivity">
<android.support.design.widget.TabLayout
style="@style/CategoryTab"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<!-- Style for a tab that displays a category name -->
<style name="CategoryTab" parent="Widget.Design.TabLayout">
<item name="tabIndicatorColor">@android:color/white</item>
<item name="tabSelectedTextColor">@android:color/white</item>
<item name="tabTextAppearance">@style/CategoryTabTextAppearance</item>
</style>
<!-- Text appearance style for a category tab -->
<style name="CategoryTabTextAppearance" parent="TextAppearance.Design.Tab">
<item name="android:textColor">#A8A19E</item>
</style>
</resources>
, когда я пытаюсь поставить шестигранной код цвета #A8A19E
вместо @style/CategoryTabTextAppearance
Безразлично» t и дайте мне ошибку, почему это происходит? хотя этот атрибут принимает значение цвета, Мне нужно объяснить, пожалуйста!
Поскольку 'tabTextAppearance' является' стиль ', а не' color'. 'textColor' - всего лишь один атрибут многих возможных в этом стиле. –
как вы знаете tabTextAppearance - это стиль, а не атрибут, где я могу найти эту информацию? –
Вы можете поместить цвет в этот стиль, используя '@color/your_color_name'. Если конечный код становится -'- @ color/your_color_name
' –