android笔记---textVIew控件,EditText控件

textView控件

1.xml格式

<TextView

   android:layout_width="fill_parent"

   android:layout_height="wrap_content"

   android:textSize="20sp"

   android:textColor="#00FF00"

   android:text="kkk"

/>

2.代码

TextView tv=new TextView(this);

tv.setText("你好");

setContentView(tv);

改变文本颜色

TextView tv=(TextView)findViewById(R.id.tv);
tv.setText(Html.fromHtml("欢迎<font color =blue>光临</font>myHOME"));


TextView tv=(TextView)findViewById(R.id.tv);
    String str="欢迎大家来到<myHOME>谢谢光临";
SpannableStringBuilder style=new SpannableStringBuilder(str);
    style.setSpan(new ForegroundColorSpan(Color.RED),0, 6, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    style.setSpan(new ForegroundColorSpan(Color.GREEN),6, 14, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    style.setSpan(new ForegroundColorSpan(Color.BLUE),14, 18, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    tv.setText(style);


 

设置超链:

 <TextView 

        android:id="@+id/tv"

        android:autoLink="all" 

        android:layout_width="fill_parent"

        android:layout_height="wrap_content" 

        android:textSize="20sp"

        android:textColor="#00FF00" 

        android:text="欢迎大家来到《myHOME》谢谢光临。\n我的博客:http://charmlo.iteye.com/\n我的电话:110" 

        />

 

 跑马灯效果

 

<TextView 

        android:id="@+id/tv"

        android:autoLink="all" 

        android:layout_width="fill_parent"

        android:layout_height="wrap_content" 

        android:textSize="20sp"

        android:textColor="#00FF00" 

        android:singleLine="true"

        android:focusable="true"

        android:ellipsize="marquee"

        android:marqueeRepeatLimit="marquee_forever"

        android:focusableInTouchMode="true"

        android:text="欢迎大家来到《myHOME》谢谢光临。我的博客:http://charmlo.iteye.com/我的电话:110" 

        />

 

EditText控件

1.去掉焦点

<EditText

    android:layout_width="0dp"

    android:layout_height="0dp"

    />

<EditText

    android:layout_width="fill_parent"

    android:layout_height="wrap_content"

    />

2.限制输入字符数

android:maxLength="3"

3.多行文本框

android:singleLine="false"

 

 

to be continued

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值