TextView、EditText

  • TextView加下划线

    tvTest.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG ); //下划线
    tvTest.getPaint().setAntiAlias(true);//抗锯齿
    
  • EditText组件drawableLeft属性设置的图片和hint设置的文字之间的距离

    <EditText 
        android:id="@+id/tel_num"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="25dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:drawablePadding="8dp"
        android:drawableLeft="@drawable/phone"
        android:hint="请输入手机号码"
     />
    
    • 代码设置 :
      // void android.widget.TextView.setCompoundDrawables(Drawable left, Drawable top, Drawable right, Drawable bottom)
      tv_xxx.setCompoundDrawables(null, xxxApplication.getContext().getResources().getDrawable(R.mipmap.xxx), null, null);
      tv_xxx.setCompoundDrawablePadding(20);
  • 行间距

    android:lineSpacingExtra="2dp"
    
  • setTextColor()的参数设置

    setTextColor(0xFF0000FF);//0xFF0000FF是int类型的数据,分组一下0x|FF|0000FF,0x是代表颜色整数的标记,ff是表示透明度,0000FF表示颜色,注意:这里0xFF0000FF必须是8个的颜色表示,不接受0000FF这种6个的颜色表示。
    
    另外还可以使用系统自带的颜色类setTextColor(android.graphics.Color.BLUE);
    
    还有就是使用资源文件进行设置setTextColor(this.getResources().getColor(R.color.blue));//通过获得资源文件进行设置。根据不同的情况R.color.blue也可以是R.string.blue或者R.drawable.blue,当然前提是需要在相应的配置文件里做相应的配置,如:
    <color name="blue">#0000FF</color>
    <drawable name="blue">#0000FF</drawable>
    <string name="blue">#0000FF</string>
    
  • 改变背景图片
    tv_title_select1.setBackgroundResource(R.mipmap.right_btn_nor);

  • 字符串截取 :

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值