该博客由两人共同维护, 初衷就是想要把在工作中遇到的弯路尽早的指出来。
把遇到的坑都尽可能的发出来讨论/学习。
我们大家都是【大自然的搬运工】。 我们建立了一个讨论群: 608988861
不介意技术大牛, 初级菜鸟进入, 希望我们能共同努力, 走向学习的道路;
如果在界面那种编写了EditText, 那么默认情况下打开该布局时, 将会直接针对该EditText弹出软键盘, 供用户输入使用。
解决方案
** android:focusable
** android:focusableInTouchMode
加入以上两个属性在包裹EditText的父布局中, 将会阻止Android的默认行为;
代码片段
代码块,例如:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="50dp"
android:layout_margin="15dp"
android:hint="*Hello , 请输入*"
android:gravity="top|left"/>
</RelativeLayout>
结尾
改分组博文将直接指明解决思路, 不具体讨论内部的代码逻辑实现。