改变Android的文本颜色 [英] change android text color

查看:347
本文介绍了改变Android的文本颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用下面code改变我的文本颜色。

I trying to change my text color by using below code.

 <TextView android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLefe="5dp"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="@color/blue"/>

但是编译器说的无法解析符号@色/蓝色。我指的是<一个href=\"http://android4beginners.com/2013/07/lesson-1-3-how-to-change-a-color-of-text-and-background-in-textview/\" rel=\"nofollow\">http://android4beginners.com/2013/07/lesson-1-3-how-to-change-a-color-of-text-and-background-in-textview/但为什么它不是为我工作?

However the compiler said cannot resolve symbol @color/blue. I refer to http://android4beginners.com/2013/07/lesson-1-3-how-to-change-a-color-of-text-and-background-in-textview/ but why it's not working for me?

colors.xml

<?xml version="1.0" encoding="utf-8"?>  

    <resources>
        <color android:name="green">#00ff00</color>
        <color android:name="red">#FF0000</color>
        <color android:name="blue">#0000FF</color>
    </resources>

编辑

在这里输入的形象描述

Mainfest.java

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.project.project" >

    <uses-permission android:name="android.permission.CAMERA" />
    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-sdk
        android:minSdkVersion="16"
        android:targetSdkVersion="18" />
    <application

        android:allowBackup="true"

        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity android:name =".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
        </activity>
        <activity
            android:name=".WorkDetailsTable">
            </activity>
        <activity android:name=".WorkForce">
        </activity>

        <activity android:name=".ListDisplay">
            </activity>
        <activity android:name=".UpdatePage">
            </activity>

        <activity android:name=".UpdatePage2">
        </activity>

    </application>

</manifest>

如何解决这一问题?

How to fix this?

推荐答案

您必须创建color.xml文件夹值象下面这样他形象

you have to create color.xml file in values folder like in he image below

和在文件写入

 <?xml version="1.0" encoding="utf-8"?>
  <resources>
   <color name="blue">#0000FF</color>
 </resources>

这篇关于改变Android的文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆