Commit 5cd173af by 刘鹏

feat : 身份证输入最后文字动态效果完成

parent 5a297706
...@@ -3,6 +3,14 @@ package com.yidianling.medical.archives ...@@ -3,6 +3,14 @@ package com.yidianling.medical.archives
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.os.Handler
import android.os.Looper
import android.os.Message
import android.text.Editable
import android.text.SpannableString
import android.text.Spanned
import android.text.TextWatcher
import android.text.style.AbsoluteSizeSpan
import android.view.* import android.view.*
import com.ydl.ydlcommon.base.BaseActivity import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.utils.StatusBarUtils import com.ydl.ydlcommon.utils.StatusBarUtils
...@@ -14,6 +22,7 @@ import com.yidianling.uikit.custom.http.ServiceImpl ...@@ -14,6 +22,7 @@ import com.yidianling.uikit.custom.http.ServiceImpl
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.medical_add_new_archives_activity.* import kotlinx.android.synthetic.main.medical_add_new_archives_activity.*
import kotlin.concurrent.thread
/** /**
...@@ -25,6 +34,9 @@ class MedicalAddNewArchivesActivity : BaseActivity() { ...@@ -25,6 +34,9 @@ class MedicalAddNewArchivesActivity : BaseActivity() {
companion object { companion object {
var mMarried = -1 var mMarried = -1
var mRelation = -1 var mRelation = -1
//之前输入内容长度
var oldLength = 0;
private val AUTOSIZE = 1027;
@JvmStatic @JvmStatic
fun start(context: Context) { fun start(context: Context) {
...@@ -32,6 +44,23 @@ class MedicalAddNewArchivesActivity : BaseActivity() { ...@@ -32,6 +44,23 @@ class MedicalAddNewArchivesActivity : BaseActivity() {
context.startActivity(starter) context.startActivity(starter)
} }
} }
private val mHandler:Handler = object :Handler(Looper.getMainLooper()){
override fun handleMessage(msg: Message?) {
super.handleMessage(msg)
if (msg?.what == AUTOSIZE){
val msp = SpannableString(et_idcard.text.toString())
msp.setSpan(
AbsoluteSizeSpan(16, true),
0,
et_idcard.text.length,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
)
et_idcard.setText(msp)
et_idcard.setSelection(et_idcard.text.length)
}
}
}
override fun layoutResId(): Int { override fun layoutResId(): Int {
return R.layout.medical_add_new_archives_activity return R.layout.medical_add_new_archives_activity
...@@ -108,6 +137,36 @@ class MedicalAddNewArchivesActivity : BaseActivity() { ...@@ -108,6 +137,36 @@ class MedicalAddNewArchivesActivity : BaseActivity() {
EditTextUtils.disableCopyAndPaste(et_name) EditTextUtils.disableCopyAndPaste(et_name)
et_idcard.addTextChangedListener(object :TextWatcher{
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
}
override fun afterTextChanged(s: Editable?) {
var sLength = s.toString().length;
if(sLength != oldLength){
val msp = SpannableString(s.toString())
msp.setSpan(
AbsoluteSizeSpan(18, true),
Math.max(s.toString().length - 1,0),
s.toString().length,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
)
oldLength = sLength;
et_idcard.setText(msp)
et_idcard.setSelection(sLength)
var message = Message()
message.what = AUTOSIZE;
mHandler.sendMessageDelayed(message,1000)
}
}
})
iv_back.setOnClickListener { finish() } iv_back.setOnClickListener { finish() }
showDialogTip() showDialogTip()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment