zoukankan      html  css  js  c++  java
  • 关于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" />
  • 相关阅读:
    类函数指针
    resource for machine learning
    蒲丰投针与蒙特卡洛模拟
    IIS5、IIS6、IIS7的ASP.net 请求处理过程比较
    CMD 命令速查手册
    Process, Thread, STA, MTA, COM object
    在托管代码中设置断点(Windbg)
    SidebySide Execution
    .NET Framework 3.5 Architecture
    Overview of the .NET Framework
  • 原文地址:https://www.cnblogs.com/huihuizhang/p/6927537.html
Copyright © 2011-2022 走看看