<Android 基础(二十二)> EditText 无法显示完全以及尝鲜Android N
来源:互联网 发布:小果软件手机 编辑:程序博客网 时间:2024/06/06 15:38
前言
最近将Android Studio更新到了2.2 ,模拟器的Android版本也来到了最新的Nougat。很令人兴奋的一件事情呢! 对, 我就是这么没出息。文章结尾来几张图。
问题
最近遇到一个问题,EditText只读的情况下,在ScrollView下无法滚动,原因应该就是滑动事件优先被ScrollView消耗,导致EditText并没有收到滚动事件,导致如是问题
解决办法:
EditText editText = (EditText) findViewById(R.id.EditText01);EtOne.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (v.getId() == R.id.comment1) { v.getParent().requestDisallowInterceptTouchEvent(true);//组织父节点消耗滑动事件 switch (event.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_UP: v.getParent().requestDisallowInterceptTouchEvent(false); break; } } return false; }});
这种情况下,EditText应该是可编辑状态,但是我们的要求是只读,也就是无法编辑,这种情况下,如果用户点击到了文本区域内,会弹出输入法,用户便可以直接输入,这个问题如何解决
解决办法:
- 阻止输入法弹出
editText = (EditText) findViewById(R.id.editText);editText.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub int inType = editText.getInputType(); // backup the input type editText.setInputType(InputType.TYPE_NULL); // disable soft input editText.onTouchEvent(event); // call native handler editText.setInputType(inType); // restore input type editText.setSelection(editText.getText().length()); return true; }});
- 阻止输入法弹出
edittext.setKeyListener(null);
Sets the key listener to be used with this TextView. This can be null
to disallow user input. Note that this method has significant and
subtle interactions with soft keyboards and other input method:
see {@link KeyListener#getInputType() KeyListener.getContentType()}
for important details. Calling this method will replace the current
content type of the text view with the content type returned by the
key listener.
Android Nougat模拟器
Android Studio2.2上的模拟器速度还是比较快的。
Google原生的内容依然是那么的干净,清晰,功能强大。模拟器的功能也是比较健全的。
N版本具体更新内容,请关注官网:
https://developer.android.com/about/versions/nougat/android-7.0.html
Android Studio 2.2
正题界面风格没有很大的变化,图标有变化,给我印象最深的是UI编辑器
编辑器中多了一个视图,上方多了一些按钮,右侧的属性可能更丰富了吧,之前我都是全部手写的,真是浪费好的开发工具。具体的更新内容请关注官网:
https://developer.android.com/studio/releases/index.html
- <Android 基础(二十二)> EditText 无法显示完全以及尝鲜Android N
- <Android 基础(二十四)> EditText
- android尝鲜
- Android 基础总结:( 二十二)JSON详解(上)
- Android EditText无法换行
- android EditText提示居右无法显示的问题
- android EditText软键盘显示隐藏以及"监听"
- Android EditText软键盘显示隐藏以及“监听”
- Android EditText软键盘显示隐藏以及“监听”
- Android EditText软键盘显示隐藏以及“监听”
- Android EditText软键盘显示隐藏以及“监听”
- Android EditText 不显示光标 以及自定义光标
- Android BLE与终端通信(二)——Android Bluetooth基础科普以及搜索蓝牙设备显示列表
- android 基础控件 EditText
- Android基础-EditText用法
- Android基础控件 -- EditText
- Android 基础控件- EditText
- android典型代码系列(二十二)------按键使上面的EditText抖动
- C语言难点总结
- CSS样式表整理(转载自博客园 lhyterry)
- 字符串匹配
- 深度理解Android InstantRun原理以及源码分析
- Exploit-Database官方GitHub仓库
- <Android 基础(二十二)> EditText 无法显示完全以及尝鲜Android N
- 文章标题 HDU 5115 : Dire Wolf (区间DP)
- C 变量 基础(一)
- flask框架实战—简单图片社交网站
- 单片机定时功能的实现
- 对象的创建过程
- 安卓数据绑定指南
- edtText限制手机号的位数为十一位
- Python 字符串处理操作