SuperEditText使用说明
控件地址:https://github.com/pvphero/SuperEditText
1.控件的功能
- EditText一键清除功能
- TextInputEditText下方提示语可以显示隐藏
- 清除按钮可以显示隐藏
- EditText 错误提示
- Layout错误提示
- 失去焦点时,提示的文字消失;获得焦点时,提示的文字显示
2.控件用法说明
- XML代码
1 | <com.vv.superedittextlib.FloatingEditTextLayout |
- Java代码
1 | public class MainActivity extends AppCompatActivity { |
- 运行效果
3.控件说明
3.1 控件组成
FloatingEditTextLayout
是一个组合控件,该控件继承自 TextInputLayout
,内部集成了ClearEditText
和 TextView
ClearEditText
是用来代替TextInputEditText
,并实现一键清除功能的EditTextTextView
该控件是用来实现中间的提示字
3.2 控件公共方法说明
FloatingEditTextLayout.getText()
获取editText的Text
FloatingEditTextLayout.setText()
设置editText的Text
FloatingEditTextLayout.setError(@Nullable CharSequence errorText)
设置editText的error
FloatingEditTextLayout.setLayoutError(@Nullable CharSequence errorText)
设置Layout的Error
FloatingEditTextLayout.setHint(@StringRes int hintRes)
设置Hint
FloatingEditTextLayout.addTextChangedListener(TextWatcher textWatcher)
监听editText的TextChange
FloatingEditTextLayout.removeTextChangedListener(TextWatcher textWatcher)
移除editText textChange的监听事件
FloatingEditTextLayout.getEditText()
获取EditText
FloatingEditTextLayout.isFloatingLabelAlwaysShown()
判断是否要一直显示提示的字
FloatingEditTextLayout.setFloatingLabelAlwaysShown()
设置提示的字是否一直显示
FloatingEditTextLayout.hideFloatTextView()
隐藏提示的字
FloatingEditTextLayout.showFloatTextView()
显示提示的字
FloatingEditTextLayout.getFloatLableText()
获取提示的字
FloatingEditTextLayout.setFloatLableText(String floatLableText)
设置提示的字
FloatingEditTextLayout.setEnabled(boolean enabled)
设置enable,如果enable=false则隐藏提示的字,如果enable=true则显示提示的字
ClearEditText.setOnFocusChangeListener()
ClearEditText设置焦点的监听事件
ClearEditText.isShowClearButton()
判断是否显示ClearButton
ClearEditText.setShowClearButton(boolean showClearButton)
设置ClearButton是否显示
ClearEditText.getIconSize()
获取Icon的大小
ClearEditText.setIconSize(int iconSize)
设置Inco的大小
License
Copyright 2018 pvphero
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.