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>

  • 相关阅读:
    用户自定义控件的嵌套问题
    ASP.NET进阶:调用Javascript
    [网络收集]FCKeditor配置和精简【附源码】
    检查session判断用户是否退出登录
    Server.Transfer VS Response.Redirect
    asp.net下ckeditor3.0.1和ckfinder_aspnet_1.4.1.1的配置方法
    Sudoku(数独)
    转自:蓝色污点的专栏
    LETTERS(字母)
    放苹果
  • 原文地址:https://www.cnblogs.com/androidsj/p/3064973.html
Copyright © 2011-2022 走看看