【问题标题】:I want to add color in TextView.. With any color of your choice [duplicate]我想在 TextView 中添加颜色。使用您选择的任何颜色 [重复]
【发布时间】:2014-02-26 14:23:49
【问题描述】:

我想获得彩色的TextView..请告诉我一个代码..用您选择的任何颜色..

    <TextView 
    android:layout_height="wrap_content" 
    android:layout_width="match_parent" 
    android:layout_margin Left="5 pt" 
    android:layout_margin Right="5 pt" 
    android:text Size="12 pt" 
    android:layout_margin Top="3 pt" 
    android:id="@+id/  Result" 
    android:gravity="center_horizontal"> 
    </TextView>

【问题讨论】:

  • 添加 android:textColor="#445566"TextView 是一个词,而不是“Text View”!!
  • 谢谢!...但我仍然收到黑色的短信:(
  • 是的,兄弟!..“文本视图”一句话我不能在这里发布..它带有红色下划线,所以我使用了空格:)

标签: android colors textview


【解决方案1】:

使用textColor XML 属性,例如:

android:textColor="#ffffff"

你的整个TextView 看起来像这样:

<TextView 
    android:layout_height="wrap_content" 
    android:layout_width="match_parent" 
    android:layout_marginLeft="5pt" 
    android:layout_marginRight="5pt" 
    android:textSize="12pt" 
    android:layout_marginTop="3pt" 
    android:id="@+id/Result" 
    android:gravity="center_horizontal"
    android:textColor="#ffffff"/> 

【讨论】:

  • 非常感谢兄弟!它起作用了:)伙计,你能不能给你的电子邮件ID,因为我在android中仍然是个菜鸟……我可以和你分享我的疑问:)
  • 很高兴它成功了!我不会给你我的电子邮件地址。我最好的建议是阅读一本关于 Android 编程的书,并尽可能多地进行测试项目。我们都必须经历这个。如果在途中出现任何问题,请随时在 SO 上提问。
  • @FD_,使用 dp/sp 单位来表示尺寸不是更好吗?
  • @2Dee:是的,dp 绝对是首选单位。
  • @FD_,PS:我在你删除之前看到了链接。先生,你让我很开心,+1 :-D
【解决方案2】:

您还可以使用一些内置颜色,例如:

android:textColor="@android:color/holo_orange_dark" 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-02-10
    • 2012-11-19
    • 1970-01-01
    • 2015-09-24
    • 2020-03-20
    • 2016-02-08
    • 1970-01-01
    • 2011-11-22
    相关资源
    最近更新 更多