自定义TextView/EditText,实现显示(或输入)小数、数字前缀(¥$...)、千分符、最大值等

DecimalTextView

自定义TextView/EditText,实现显示(或输入)小数、数字前缀(¥$…)、千分符、最大值等。

API > 14


####DecimalTextView演示
DecimalTextView演示
####DecimalEditText演示
DecimalEditText演示


	// 1.添加jitpack仓库
	allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}
	// 2.添加项目依赖(last-version替换为最新版本号)
	dependencies {
		compile 'com.github.parfoismeng:decimaltextview:last-version'
	}

  • 属性说明
	<!-- 数字符号 默认¥ -->
	<attr name="decimal_symbol" format="string" />
	<!-- 数字符号的字体大小 默认与字体大小一致(-1) -->
	<attr name="decimal_symbol_size" format="dimension" />
	<!-- 是否显示数字符号 默认true -->
	<attr name="decimal_show_symbol" format="boolean" />
	<!-- 是否显示数字分号 默认false -->
	<attr name="decimal_show_commas" format="boolean" />
	<!-- 上限数字 默认1000000 -->
	<attr name="decimal_upper" format="float" />
	<!-- 小数点后位数 默认2位 -->
	<attr name="decimal_scale" format="integer" />
	<!-- 小数点后是否用0填充 默认false -->
	<attr name="decimal_fill_zero" format="boolean" />
  • xml里直接引用
	<com.parfoismeng.decimaltextviewlib.widget.DecimalTextView
	        android:layout_width="match_parent"
	        android:layout_height="wrap_content"
	        app:decimal_symbol="¥"
	        app:decimal_symbol_size="12sp"
	        app:decimal_show_symbol="true"
	        app:decimal_show_commas="false"
	        app:decimal_upper="1000000"
	        app:decimal_scale="2"
	        app:decimal_fill_zero="false" />

	<com.parfoismeng.decimaltextviewlib.widget.DecimalEditText
	        android:layout_width="match_parent"
	        android:layout_height="wrap_content"
	        app:decimal_symbol="¥"
	        app:decimal_symbol_size="12sp"
	        app:decimal_show_symbol="true"
	        app:decimal_show_commas="false"
	        app:decimal_upper="1000000"
	        app:decimal_scale="2"
	        app:decimal_fill_zero="false" />

####Demo下载地址:https://fir.im/sajf
Demo下载二维码


###更新记录

  1. 控件名移除“Parfois”字符,修复hint无效问题 fixbug issues1 —— 1.0.0(2018.12.18)
  2. 修复EditText输入问题 —— 0.0.8(2018.01.26)
  3. 修复0.00.0的问题 —— 0.0.4(2018.01.13)
  4. 添加数字符号可以设置字体大小 —— 0.0.3(2017.11.17)
  5. 更新README.md —— 0.0.2(2017.11.14)
  6. 初始提交 —— 0.0.1(2017.11.13)
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值