如何在Android应用程序中为所有文本设置文本颜色? [英] How to set text color in android app for all text?

查看:81
本文介绍了如何在Android应用程序中为所有文本设置文本颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为我的android应用程序定义默认的文本颜色.

I want to define a default text color for my android app.

我有一个基本的活动类,所有活动都从该类扩展而来,我认为这可能是定义颜色的好地方.

I have a base activity class, that all activities are extended from it and I thought this might be a good place to define the colors.

如果不是更好的解决方案?也许是样式?

If not what is a better solution? Maybe styles?

麻烦是,这对我来说是新事物,所以请随时向我提出建议,并提供代码段和解释.

Trouble is this, all is new to me, so feel free to advise me and provide code snippets and explanations as well.

这是我的基类的样子.如您所见,它是空的

This is what my base class looks like. As you can see it's pretty empty

package com.ccslocal.mobile.quiz.jls;

import android.app.Activity;
import android.os.Bundle;

public class BaseActivity extends Activity {
    //set up app preferences here
}

推荐答案

是的,您可以使用样式来实现.或者,您可以使用 TextView.getTextColors().getDefaultColor()设置默认文本颜色.实际上,我从未使用过它,但我认为这可能会对您有所帮助.

Yes you are right you can make that using style. Or you can use TextView.getTextColors().getDefaultColor() for set default text color. Actually I never used this but I think it may be help you.

对于样式

<style name="TextColor">
    <item name="android:textColor">#00FF00</item>
</style>      

然后在布局文件中

<TextView  style="@style/TextColor" />

这篇关于如何在Android应用程序中为所有文本设置文本颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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