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 中禁用滚动选项


- Android viewpager检测滑动超出范围 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- Android - 拆分 Drawable 2022-01-01