Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 为什么文本视图中的文本不改变颜色?_Android_Textview - Fatal编程技术网

Android 为什么文本视图中的文本不改变颜色?

Android 为什么文本视图中的文本不改变颜色?,android,textview,Android,Textview,我对某些无法改变颜色的文本视图有意见。我不知道为什么它不起作用 我在资源/colors.xml <?xml version="1.0" encoding="utf-8"?> <resources> <color name="colorPrimary">#FDCDB2</color> <color name="colorPrimaryDark">#E2896B</color> <color nam

我对某些无法改变颜色的文本视图有意见。我不知道为什么它不起作用

我在
资源/colors.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="colorPrimary">#FDCDB2</color>
    <color name="colorPrimaryDark">#E2896B</color>
    <color name="colorAccent">#FF4081</color>
    <color name="mainBackground">#F6F5F5</color>
</resources>

请注意图像中带有棕色色调的文本,这是所需的颜色。“说明”、“正文”和“说明”已决定为浅灰色

下面是我的布局代码:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:orientation="vertical">

    <!--make whole layout scrollable-->
    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="?attr/actionBarSize"
        android:orientation="vertical">

        <!--nested view can only have one child-->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:textColor="@color/colorPrimary"
            >

            <!-- main image of the brew method-->
            <ImageView
                android:id="@+id/topImageIV"
                android:layout_width="300dp"
                android:layout_height="300dp"
                android:layout_gravity="center|top"
                android:background="@color/colorPrimary"
                android:focusableInTouchMode="true" />

            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <!--layout for the brew parameteres-->
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/brew_method_parameters"
                    android:orientation="horizontal"
                    android:padding="8dp"
                    android:weightSum="3">

                    <!--layout for the weight-->
                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_gravity="center_horizontal"
                        android:layout_weight="1"
                        android:orientation="vertical">

                        <!--top row of the weight includes image-->
                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="30dp"
                            android:gravity="center"
                            android:orientation="horizontal">

                            <!--weight image icon-->
                            <ImageView
                                android:id="@+id/weight_icon_IV"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:focusableInTouchMode="true"
                                android:src="@drawable/ic_weight" />

                            <!--weight parameter set dynamically-->
                            <TextView
                                android:id="@+id/TV_servingDose"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:gravity="center"
                                android:hint="16 g"
                                android:textColor="@color/colorPrimaryDark" />
                        </LinearLayout>

                        <!--serving size set dynamically-->
                        <TextView
                            android:id="@+id/TV_servingNumber"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:hint="1 Serving"
                            android:paddingLeft="12dp"
                            android:textColor="@color/colorPrimaryDark" />
                    </LinearLayout>

                    <!--layout for time requirement-->
                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_gravity="center_horizontal"
                        android:layout_weight="1"
                        android:orientation="vertical">

                        <!--top row of time requirement-->
                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="30dp"
                            android:gravity="center"
                            android:orientation="horizontal">

                            <!--time icon-->
                            <ImageView
                                android:id="@+id/timer_icon_IV"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:focusableInTouchMode="true"
                                android:src="@drawable/ic_clock" />

                            <!--brew time set dynamically-->
                            <TextView
                                android:id="@+id/TV_timer"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:gravity="center"
                                android:hint="4:00"
                                android:textColor="@color/colorPrimaryDark" />
                        </LinearLayout>

                        <!--brew time label-->
                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:paddingLeft="15dp"
                            android:text="Brew Time"
                            android:textColor="@color/colorPrimaryDark" />

                    </LinearLayout>
                    <!--layout for grind size-->
                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_gravity="center_horizontal"
                        android:layout_weight="1"
                        android:orientation="vertical">

                        <!--top row of grind size includes image-->
                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="30dp"
                            android:gravity="center"
                            android:orientation="horizontal">

                            <!--icon for grind-->
                            <ImageView
                                android:id="@+id/grind_icon_IV"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:focusableInTouchMode="true"
                                android:src="@drawable/ic_grinder" />

                            <!--grind description set dynamically-->
                            <TextView
                                android:id="@+id/TV_grindSetting"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:gravity="center"
                                android:hint="@string/grind_size_coarse"
                                android:textColor="@color/colorPrimaryDark" />
                        </LinearLayout>
                        <!--grind setting description-->
                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="0dp"
                            android:layout_weight="1"
                            android:gravity="center"
                            android:paddingLeft="12dp"
                            android:text="@string/grind_setting"
                            android:textColor="@color/colorPrimaryDark" />
                    </LinearLayout>
                </LinearLayout>
            </android.support.v7.widget.CardView>

            <!--description of brewmethod layout-->
            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="8dp"
                android:orientation="vertical"
                app:cardCornerRadius="2dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@color/mainBackground"
                    android:orientation="vertical">

                    <!--description label-->
                    <TextView
                        android:id="@+id/description_header_TV"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/brew_method_description"
                        android:paddingStart="16dp"
                        android:textColor="@color/colorPrimaryDark"
                        android:textSize="24sp" />

                    <!--description text-->
                    <TextView
                        android:id="@+id/brew_method_description_TV"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/bio_aeropress"
                        android:paddingBottom="8dp"
                        android:paddingRight="16dp"
                        android:paddingStart="16dp"
                        android:textColor="@color/colorPrimaryDark" />
                </LinearLayout>
            </android.support.v7.widget.CardView>

            <!--instructions label-->
            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="8dp"
                android:orientation="vertical"
                app:cardCornerRadius="2dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@color/mainBackground"
                    android:orientation="vertical">

                    <TextView
                        android:id="@+id/brew_method_instructions_title_TV"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:backgroundTint="@color/colorPrimaryDark"
                        android:hint="@string/brew_method_instructions"
                        android:paddingStart="16dp"
                        android:textSize="24sp" />

                    <!--instuctions recyclerview. set using InstructionListAdapter-->
                    <android.support.v7.widget.RecyclerView
                        android:id="@+id/rvInstructions"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:minHeight="0dp">

                    </android.support.v7.widget.RecyclerView>
                </LinearLayout>
            </android.support.v7.widget.CardView>
        </LinearLayout>
    </android.support.v4.widget.NestedScrollView>


    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay"
            app:titleTextColor="@color/colorPrimaryDark" />

    </android.support.design.widget.AppBarLayout>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        android:backgroundTint="@color/colorPrimaryDark"
        app:srcCompat="@android:drawable/ic_lock_idle_alarm" />


</android.support.design.widget.CoordinatorLayout>

弄清楚发生了什么:

在有颜色问题的文本视图中,我使用

android:hint=“@string/brew\u方法\u说明

而不是

android:text=“@string/brew\u方法\u说明


切换设置实际文本启用了颜色更改。

可能您的android:主题对此有一定影响。@statosdotcom我在上面的编辑中包含了
值/style.xml
。谢谢你,这些款式没有提及那些灰色的色调。你的清单指向AppTheme,对吗?好啊然后是时候覆盖你的主题来获得你需要的。为TextView创建一个主题,因为xml上似乎有某种东西禁止使用它来获得所需的颜色。也许在你的主题中硬编码你会找到你的方式。(咖啡爱好者万岁)你能将你的活动代码发布到你可以动态设置值的地方吗?@statosdotcom检查我的更新,我创建了一个样式并尝试应用它。没变。
    android:textColor="@color/colorPrimaryDark"
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:orientation="vertical">

    <!--make whole layout scrollable-->
    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="?attr/actionBarSize"
        android:orientation="vertical">

        <!--nested view can only have one child-->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:textColor="@color/colorPrimary"
            >

            <!-- main image of the brew method-->
            <ImageView
                android:id="@+id/topImageIV"
                android:layout_width="300dp"
                android:layout_height="300dp"
                android:layout_gravity="center|top"
                android:background="@color/colorPrimary"
                android:focusableInTouchMode="true" />

            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <!--layout for the brew parameteres-->
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@drawable/brew_method_parameters"
                    android:orientation="horizontal"
                    android:padding="8dp"
                    android:weightSum="3">

                    <!--layout for the weight-->
                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_gravity="center_horizontal"
                        android:layout_weight="1"
                        android:orientation="vertical">

                        <!--top row of the weight includes image-->
                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="30dp"
                            android:gravity="center"
                            android:orientation="horizontal">

                            <!--weight image icon-->
                            <ImageView
                                android:id="@+id/weight_icon_IV"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:focusableInTouchMode="true"
                                android:src="@drawable/ic_weight" />

                            <!--weight parameter set dynamically-->
                            <TextView
                                android:id="@+id/TV_servingDose"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:gravity="center"
                                android:hint="16 g"
                                android:textColor="@color/colorPrimaryDark" />
                        </LinearLayout>

                        <!--serving size set dynamically-->
                        <TextView
                            android:id="@+id/TV_servingNumber"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:hint="1 Serving"
                            android:paddingLeft="12dp"
                            android:textColor="@color/colorPrimaryDark" />
                    </LinearLayout>

                    <!--layout for time requirement-->
                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_gravity="center_horizontal"
                        android:layout_weight="1"
                        android:orientation="vertical">

                        <!--top row of time requirement-->
                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="30dp"
                            android:gravity="center"
                            android:orientation="horizontal">

                            <!--time icon-->
                            <ImageView
                                android:id="@+id/timer_icon_IV"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:focusableInTouchMode="true"
                                android:src="@drawable/ic_clock" />

                            <!--brew time set dynamically-->
                            <TextView
                                android:id="@+id/TV_timer"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:gravity="center"
                                android:hint="4:00"
                                android:textColor="@color/colorPrimaryDark" />
                        </LinearLayout>

                        <!--brew time label-->
                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:paddingLeft="15dp"
                            android:text="Brew Time"
                            android:textColor="@color/colorPrimaryDark" />

                    </LinearLayout>
                    <!--layout for grind size-->
                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                        android:layout_gravity="center_horizontal"
                        android:layout_weight="1"
                        android:orientation="vertical">

                        <!--top row of grind size includes image-->
                        <LinearLayout
                            android:layout_width="match_parent"
                            android:layout_height="30dp"
                            android:gravity="center"
                            android:orientation="horizontal">

                            <!--icon for grind-->
                            <ImageView
                                android:id="@+id/grind_icon_IV"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:focusableInTouchMode="true"
                                android:src="@drawable/ic_grinder" />

                            <!--grind description set dynamically-->
                            <TextView
                                android:id="@+id/TV_grindSetting"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:gravity="center"
                                android:hint="@string/grind_size_coarse"
                                android:textColor="@color/colorPrimaryDark" />
                        </LinearLayout>
                        <!--grind setting description-->
                        <TextView
                            android:layout_width="match_parent"
                            android:layout_height="0dp"
                            android:layout_weight="1"
                            android:gravity="center"
                            android:paddingLeft="12dp"
                            android:text="@string/grind_setting"
                            android:textColor="@color/colorPrimaryDark" />
                    </LinearLayout>
                </LinearLayout>
            </android.support.v7.widget.CardView>

            <!--description of brewmethod layout-->
            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="8dp"
                android:orientation="vertical"
                app:cardCornerRadius="2dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@color/mainBackground"
                    android:orientation="vertical">

                    <!--description label-->
                    <TextView
                        android:id="@+id/description_header_TV"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/brew_method_description"
                        android:paddingStart="16dp"
                        android:textColor="@color/colorPrimaryDark"
                        android:textSize="24sp" />

                    <!--description text-->
                    <TextView
                        android:id="@+id/brew_method_description_TV"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:hint="@string/bio_aeropress"
                        android:paddingBottom="8dp"
                        android:paddingRight="16dp"
                        android:paddingStart="16dp"
                        android:textColor="@color/colorPrimaryDark" />
                </LinearLayout>
            </android.support.v7.widget.CardView>

            <!--instructions label-->
            <android.support.v7.widget.CardView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="8dp"
                android:orientation="vertical"
                app:cardCornerRadius="2dp">

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:background="@color/mainBackground"
                    android:orientation="vertical">

                    <TextView
                        android:id="@+id/brew_method_instructions_title_TV"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:backgroundTint="@color/colorPrimaryDark"
                        android:hint="@string/brew_method_instructions"
                        android:paddingStart="16dp"
                        android:textSize="24sp" />

                    <!--instuctions recyclerview. set using InstructionListAdapter-->
                    <android.support.v7.widget.RecyclerView
                        android:id="@+id/rvInstructions"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:minHeight="0dp">

                    </android.support.v7.widget.RecyclerView>
                </LinearLayout>
            </android.support.v7.widget.CardView>
        </LinearLayout>
    </android.support.v4.widget.NestedScrollView>


    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay"
            app:titleTextColor="@color/colorPrimaryDark" />

    </android.support.design.widget.AppBarLayout>

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        android:backgroundTint="@color/colorPrimaryDark"
        app:srcCompat="@android:drawable/ic_lock_idle_alarm" />


</android.support.design.widget.CoordinatorLayout>