Disable scroll option in EditText(在 EditText 中禁用滚动选项)
问题描述
当用户在 EditText 上输入更多字符时禁用滚动选项.我需要减小字体/类型大小,而不是滚动选项.
Disable scroll option in EditText when the user enter more characters on that. Instead of scroll option i need to reduce the font/type size.
我目前正在做的是获取字符数,如果超出特定限制,则减少字体大小.我想要做的是当滚动选项被激活时,需要减小大小.
What i am currently doing is getting the count of characters and if it is exceeding a particular limit reducing the font size. What i want to do is when the scrolling option getting activated, need to reduce the size.
qQuestionEditText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before,
int count) {
// TODO Auto-generated method stub
qCount.setText(String.valueOf(200 - s.length()));
if (qQuestionEditText.length() > 180) {
qQuestionEditText.setTextSize(20);
} else if (qQuestionEditText.length() > 150) {
qQuestionEditText.setTextSize(22);
} else if (qQuestionEditText.length() > 120) {
qQuestionEditText.setTextSize(24);
} else if (qQuestionEditText.length() > 90) {
qQuestionEditText.setTextSize(26);
} else if (qQuestionEditText.length() > 60) {
qQuestionEditText.setTextSize(28);
} else if (qQuestionEditText.length() > 30) {
qQuestionEditText.setTextSize(30);
} else {
qQuestionEditText.setTextSize(32);
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
});
推荐答案
你可以试试 setMovementMethod() 它将禁用 EditText 文本滚动.但是你必须管理文本大小.
You can try setMovementMethod() It will disable the EditText text scrolling. But you have to manage text size.
editText.setMovementMethod(null);
editText.setMovementMethod(null);
希望对你有帮助...
这篇关于在 EditText 中禁用滚动选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 EditText 中禁用滚动选项
基础教程推荐
- 在 iOS8 中无法获得正确的键盘高度值 2022-01-01
- Android:STATE_SELECTED不工作 2022-01-01
- 新的@SystemApi 注解是什么意思,和@hide 有什么区别 2022-01-01
- 我的 UIImageView 的任务 2022-01-01
- 在 appComponent dagger 2 中动态添加测试模块? 2022-01-01
- - (CGRect)convertRect:(CGRect)rect toView:(UIView *)view 如何工作 2022-01-01
- 可可/目标C(OSX不是iOS)从子对象访问父对象 2022-01-01
- 在 Android 模拟器中激活网络位置提供程序? 2022-01-01
- 如何将多个组件添加到 PickerView? 2022-01-01
- 突出显示朗读文本(在 iPhone 的故事书类型应用程序中) 2022-01-01
