zoukankan      html  css  js  c++  java
  • TextView 内容设置成上下滑动 和 代码设置字体颜色

            <TextView
                android:id="@+id/tv_xieyi"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginTop="15dip"
                android:layout_weight="1"
                android:gravity="left"
                android:scrollbars="vertical"
                android:singleLine="false"
                android:text="@string/text_xieyi"
                android:textColor="@android:color/black"
                android:textSize="18dp"
                android:textStyle="bold" />
    TextView tv_xieyi = (TextView) this.findViewById(R.id.tv_xieyi);
    /** 设置实例化滚动方法 */
    tv_xieyi.setMovementMethod(ScrollingMovementMethod.getInstance());

    setTextColor(0xFF0000FF); //0xFF0000FF是int类型的数据,分组一下0x|FF|0000FF,0x是代表颜色整数的标记,ff是表示透明度,0000FF表示颜色,注意:这里0xFF0000FF必须是8个的颜色表示,不接受0000FF这种6个的颜色表示。

     

    另外还可以使用系统自带的颜色类

    setTextColor(android.graphics.Color.BLUE);

    还有就是使用资源文件进行设置

    setTextColor(this.getResources().getColor(R.color.blue));  //通过获得资源文件进行设置。根据不同的情况R.color.blue也可以是R.string.blue或者R.drawable.blue,当然前提是需要在相应的配置文件里做相应的配置,如:

    <color name="blue">#0000FF</color>

    <drawable name="blue">#0000FF</drawable>

    <string name="blue">#0000FF</string>

  • 相关阅读:
    phpstorm常用快捷键
    tp3.2.3运用phpexcel将excel文件导入mysql数据库
    TP3.2加载外部PHPexcel类,实现导入和导出
    Navicat常用快捷键
    thnkphp框架面试问题
    PHPSQL注入
    PHP4个载入语句的区别
    goflyway简单使用
    ubuntu16.04 HyperLedger Fabric 1.2.0 开发环境搭建
    DApp demo之pet-shop
  • 原文地址:https://www.cnblogs.com/androidsj/p/3064973.html
Copyright © 2011-2022 走看看