zoukankan      html  css  js  c++  java
  • Android代码中设置字体大小,字体颜色,显示两种颜色.倒计时效果

    Android代码中设置字体大小,字体颜色,显示两种颜色

    在xml文件中字体大小用的像素

    <TextView
    
               android:id="@+id/uppaid_time"
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:layout_below="@+id/title"
               android:layout_centerHorizontal="true"
               android:layout_marginTop="@dimen/dip_8"
               android:text="超过15分钟未支付,订单自动取消(还剩:xxx)"
               android:textColor="#888"
               android:textSize="@dimen/dip_12" />
    

    <dimen name="dip_12">12dp</dimen>

    如果在代码中想动态改变字体属性,于是直接用
    大小:
    uppaid_time.setTextSize(TypedValue.COMPLEX_UNIT_PX,getResources().getDimension(R.dimen.dip_18));
    颜色:

      uppaid_time.setTextColor(Color.BLACK);  //方法一
    
      uppaid_time.setTextColor(Color.parseColor("#909090"));   //方法二
      uppaid_time.setTextColor(getResources().getColor(R.color.white))   //方法三
    

    两种颜色显示:

          String content = "<font color="#2b92f2">" +"0030 5462 3645 "+"</font>";
          uppaid_time.setText(Html.fromHtml("兑换码: " + content));
    

    效果图:

    当然:看了这篇博客,你还可以显示下面这种效果,有需要的留言,很简单,就是写个倒计时类。顺便用一下两种颜色显示的效果
    效果图:

    谢谢你来过

  • 相关阅读:
    Windows下git使用代理服务器的设置方法
    SQL backup&restore
    css3 随记
    HTML5 上传图片预览
    jQuery.event.move
    css3 html5 手机设备 列表的弹回和加速移动
    16进制与utf-8
    android 使用现成做get请求
    android 往sd卡中写入文件
    android 遍历控件
  • 原文地址:https://www.cnblogs.com/wzqnxd/p/9011483.html
Copyright © 2011-2022 走看看