public class CounterView extends View implements OnClickListener { // 定义画笔 private Paint mPaint; // 用于获取文字的宽和高 private Rect mBounds; // 计数值,每点击一次本控件,其值增加1 private int mCount; public CounterView(Context context, AttributeSet attrs) { super(context, attrs); // 初...
Example 10Source File: TextInputLayout.java From material-components-android with Apache License 2.0 5 votes private static void updateCounterContentDescription( @NonNull Context context, @NonNull TextView counterView, int length, int counterMaxLength, boolean counterOverflowed) { counterView.s...
mCounterView.setId(R.id.textinput_counter);if(mTypeface !=null) { mCounterView.setTypeface(mTypeface); } mCounterView.setMaxLines(1);try{ TextViewCompat.setTextAppearance(mCounterView, mCounterTextAppearance); }catch(Exception e) {// Probably caused by our theme not extending from Theme.Design...
setCharCounter(textInputEditText, tvCounterView, maxCharCount, countDown); /** * set max length * this method sets max text length for text view * * @param textView - text view on which you want to set max length * @param maxLength - length to set on text view **/ UiUtils.set...
mCounterView.setText(getContext().getString(R.string.character_counter_pattern, length, mCounterMaxLength)); }if(mEditText !=null&& wasCounterOverflowed != mCounterOverflowed) { updateLabelState(false); updateEditTextBackground(); } }
// Counter.View.tsximport{CounterViewModel}from'./Counter.ViewModel'import{useVM}from'hooks-view-model'constCounterView=()=>{const{useCurrentState,increment,changeUserAge}=useVM(CounterViewModel,{count:0,// as props passed to CounterViewModel})const{user,count}=useCurrentState({user:{name:'nilu...
Example 10Source File: TextInputLayout.java From material-components-android with Apache License 2.0 5 votes private static void updateCounterContentDescription( @NonNull Context context, @NonNull TextView counterView, int length, int counterMaxLength, boolean counterOverflowed) { counterView.set...
checkResourceId(mCounterTextColorResId); if (mCounterTextColorResId != INVALID_ID) { TextView counterView = getCounterView(); if (counterView != null) { counterView.setTextColor(SkinCompatResources.getColor(getContext(), mCounterTextColorResId)); updateEditTextBackgroundInternal(); } } } ...
private void applyCounterTextColorResource() { mCounterTextColorResId = SkinCompatHelper.checkResourceId(mCounterTextColorResId); if (mCounterTextColorResId != INVALID_ID) { TextView counterView = getCounterView(); if (counterView != null) { // SkinLog.e(TAG, "mCounterTextColor = " +Integer....