• 关于TextView 的属性


    一、设置不同的字体和颜色值:
    questionDesTextView=(TextView)findViewById(R.id.question_des); SpannableStringBuilder builder = new SpannableStringBuilder(questionDesTextView.getText().toString()); //ForegroundColorSpan 为文字前景色,BackgroundColorSpan为文字背景色 ForegroundColorSpan blackSpan = new ForegroundColorSpan(Color.BLACK); ForegroundColorSpan graySpan=new ForegroundColorSpan(Color.GRAY);
    //第二个参数是开始的下标,第三个参数是结束的下标 builder.setSpan(blackSpan, 0,4, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); builder.setSpan(graySpan,4,9, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); questionDesTextView.setText(builder);

    http://aichixihongshi.iteye.com/blog/1207503

    二、设置字间距

    字间距

    textView有一个属性android:textScaleX是调节字间距的,它的值是一个float型。查看源代码,默认textView 此属性是使用的是:

    android.internal.R.styleable.TextView_textScaleX

    setTextScaleX(a.getFloat(attr, 1.0f));

    
    
    

    行间距

    Android系统中TextView默认显示中文时会比较紧凑,不是很美观。为了让每行保持一定的行间距,可以设置属性android:lineSpacingExtra或android:lineSpacingMultiplier。

    关于Android下TextView中文换行问题,可查看Android自定义view-文本自动换行。

    1、android:lineSpacingExtra
    设置行间距,如”3dp”。

    2、android:lineSpacingMultiplier
    设置行间距的倍数,如”1.2″。

    参考代码:

    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:lineSpacingExtra="3dp"
    android:lineSpacingMultiplier="1.5"
    android:textStyle="bold" />
  • 相关阅读:
    点对点风格软件架构模式
    《XXX重大技术需求征集系统》的可用性和可修改性战术分析
    淘宝网应用场景分析
    《架构漫谈》读后感
    《软件需求模式》阅读笔记06
    hdfs会出现的一些问题
    经常使用的架构模式之一——客户端-服务器模式
    阅读《大型网站技术架构》
    以《淘宝网》为例分析质量属性
    架构漫谈读后感
  • 原文地址:https://www.cnblogs.com/huihuizhang/p/6927537.html
Copyright © 2020-2023  润新知