Android(安卓)WebView 禁止输入
16lz
2021-01-25
开发过程中,有时需要显示以前输入的数据,且不能修改。搜了网上有重写WebView的onTouchEvent方法,直接return false,但测试WebView将不能响应滚动事件。
后来查看文档,找到如下方法:
/** * Set the descendant focusability of this view group. This defines the relationship * between this view group and its descendants when looking for a view to * take focus in {@link #requestFocus(int, android.graphics.Rect)}. * * @param focusability one of {@link #FOCUS_BEFORE_DESCENDANTS}, {@link #FOCUS_AFTER_DESCENDANTS}, * {@link #FOCUS_BLOCK_DESCENDANTS}. */ public void setDescendantFocusability(int focusability)
/** * This view will get focus before any of its descendants. */ public static final int FOCUS_BEFORE_DESCENDANTS = 0x20000; /** * This view will get focus only if none of its descendants want it. */ public static final int FOCUS_AFTER_DESCENDANTS = 0x40000; /** * This view will block any of its descendants from getting focus, even * if they are focusable. */ public static final int FOCUS_BLOCK_DESCENDANTS = 0x60000;
如上说明可知,通过设置FOCUS_BLOCK_DESCENDANTS,可以屏蔽子控件获取焦点。页面将不会弹出输入键盘,从而实现不可编辑。
更多相关文章
- Android(安卓)系统设置默认launcher
- 解决init: sys_prop: permission denied uid:1003 name:service.
- Android(安卓)完全退出应用程序back和home键
- Android(安卓)Studio中如何解决重复依赖导致的app:transformClas
- Android常见的几种RuntimeException
- Android中利用Handler实现消息的分发机制(一)
- 手机锁屏后再解锁保存activity状态
- 使用ImageSpan图标不截断的方法
- 使用Android-PullToRefresh实现下拉刷新功能