• [一] TextView


    //Alt + ?实现代码的自动补全
    //res/values/strings.xml  目录下面实现类似于c++的宏定义
    <string name="hello">Hello  Notebook!!</string>
    
    <TextView android:text="@string/hello" />//显示的是调用的内容
    android:textSize="20sp" //字体大小用sp作为单位,宽度,高度用dp
    android:textColor="#00FF00"//设置字体颜色为绿色
    android:id="tv"  //定义控件的id
    
    TextView tv=(TextView)findViewById(R.id.tv);
    String str="欢迎大家!!这个是一个textview的演示!! ";
    SpannableStringBuilder style=new SpannableStringBuilder(str);
    style.setSpan(new ForegroundColorSpan(Color.RED), 0, 6, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    style.setSpan(new ForegroundColorSpan(Color.GREEN), 6, 21, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    style.setSpan(new ForegroundColorSpan(Color.BLUE), 21, 34, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    tv.setText(style);
    //设置TextView的局部显示的颜色和显示的内容
    
    设置超链:可以包括web的博客访问和phone num等。
    
    android:autoLink="web" //设置web访问,同理phone等也可以有下滑线
    //跑马灯效果
    android:singleLine="true" //文字单行显示,不可缺
    android:focusable="true"
    android:ellipsize="marquee"
    android:marqueeRepeatLimit="marquee_forever"
    android:focusableInTouchMode="true"
    View Code
  • 相关阅读:
    C# 小规模查找集合性能测试
    高级前端开发不可或缺的知识
    移动前端开发-单页应用(spa)模型
    移动开发之用视频做背景
    纯CSS打造忙碌光标
    移动前端开发之数据库操作篇
    如何从源码中学习javascript
    Deffered.js的实现原理
    Codeforces Round #381 (Div. 2)
    2017 ZSTU寒假排位赛 #6
  • 原文地址:https://www.cnblogs.com/zhang1107/p/3092725.html
Copyright © 2020-2023  润新知