不可见的 PopupWindow 延迟键盘可访问性 (EditText)
invisible PopupWindow delays keyboard accessibility (EditText)
有谁知道为什么当我点击一个非空的 EditText 时,我的键盘会停止响应几秒钟?
这是包含 Logcat 信息的流程:
- 如果我点击一个空的 EditText。一切都好。我可以开始打字了。 Logcat.
没有什么奇怪的
- 如果我单击一个非空的 EditText,我将无法在键盘上键入 5 秒(大约)。在这种情况下,Logcat 显示:
--
D/ViewRootImpl@91ef75b[PopupWindow:4f1ca58]: setView = android.widget.PopupWindow$PopupDecorView{cef3bf8 V.E...... ......I. 0,0-0,0} TM=true MM=false
D/ViewRootImpl@91ef75b[PopupWindow:4f1ca58]: dispatchAttachedToWindow
V/Surface: sf_framedrop debug : 0x4f4c, game : false, logging : 0
D/ViewRootImpl@91ef75b[PopupWindow:4f1ca58]: Relayout returned: old=[0,0][0,0] new=[80,1080][1160,3300] result=0x7 surface={valid=true 535477391360} changed=tru
几秒钟后我得到:
D/ViewRootImpl@2169ec9[PopupWindow:f857c1b]: dispatchDetachedFromWindow
D/InputEventReceiver: channel '9df2d1e PopupWindow:f857c1b (client)' ~ Disposing input event receiver.
channel '9df2d1e PopupWindow:f857c1b (client)' ~NativeInputEventReceiver.
然后我就可以开始打字了。
我不知道这个 PopupWindow
是从哪里来的,也不知道为什么它只在 EditText
不为空时才在 Logcat
中触发。
PS:我也注意到当我长按 EditText
打开弹出菜单(copy/paste/...等),菜单有一个奇怪的 margin/padding 并且文本没有居中。
代码如下:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical"
android:paddingTop="@dimen/paddingLarge">
<EditText
android:id="@+id/etEmail"
style="@style/SignUpEditText"
android:hint="@string/email"
android:imeOptions="actionNext"/>
<EditText
android:id="@+id/etPassword"
style="@style/SignUpEditText"
android:layout_marginTop="@dimen/paddingSmall"
android:hint="@string/password"
android:imeOptions="actionDone"
android:inputType="textPassword"/>
<com.tremend.indieframe.ui.custom_button.IndieButton
android:id="@+id/btLogin"
android:layout_width="@dimen/loginButtonWidth"
android:layout_height="@dimen/loginButtonHeight"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/paddingXXLarge"
android:background="@drawable/round_button_white_shape"
android:text="@string/login"
android:textColor="@color/colorAccent"
android:textSize="@dimen/fsXLarge"
app:font_type="SemiBold" />
</LinearLayout>
在我的片段中,我使用 ButterKnife 绑定视图:
@BindView(R.id.etEmail)
EditText etEmail;
@BindView(R.id.etPassword)
EditText etPassword;
我使用的唯一一行是:
etEmail.getBackground().setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_IN);
etPassword.getBackground().setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_IN);
已修复!
我的 EditText style.xml 中的下面这行搞砸了整个事情。
<item name="android:textSelectHandle">@color/transparent</item>
但是我的弹出菜单仍然有问题 "cropped" :
有谁知道为什么当我点击一个非空的 EditText 时,我的键盘会停止响应几秒钟?
这是包含 Logcat 信息的流程:
- 如果我点击一个空的 EditText。一切都好。我可以开始打字了。 Logcat. 没有什么奇怪的
- 如果我单击一个非空的 EditText,我将无法在键盘上键入 5 秒(大约)。在这种情况下,Logcat 显示:
--
D/ViewRootImpl@91ef75b[PopupWindow:4f1ca58]: setView = android.widget.PopupWindow$PopupDecorView{cef3bf8 V.E...... ......I. 0,0-0,0} TM=true MM=false
D/ViewRootImpl@91ef75b[PopupWindow:4f1ca58]: dispatchAttachedToWindow
V/Surface: sf_framedrop debug : 0x4f4c, game : false, logging : 0
D/ViewRootImpl@91ef75b[PopupWindow:4f1ca58]: Relayout returned: old=[0,0][0,0] new=[80,1080][1160,3300] result=0x7 surface={valid=true 535477391360} changed=tru
几秒钟后我得到:
D/ViewRootImpl@2169ec9[PopupWindow:f857c1b]: dispatchDetachedFromWindow
D/InputEventReceiver: channel '9df2d1e PopupWindow:f857c1b (client)' ~ Disposing input event receiver.
channel '9df2d1e PopupWindow:f857c1b (client)' ~NativeInputEventReceiver.
然后我就可以开始打字了。
我不知道这个 PopupWindow
是从哪里来的,也不知道为什么它只在 EditText
不为空时才在 Logcat
中触发。
PS:我也注意到当我长按 EditText
打开弹出菜单(copy/paste/...等),菜单有一个奇怪的 margin/padding 并且文本没有居中。
代码如下:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical"
android:paddingTop="@dimen/paddingLarge">
<EditText
android:id="@+id/etEmail"
style="@style/SignUpEditText"
android:hint="@string/email"
android:imeOptions="actionNext"/>
<EditText
android:id="@+id/etPassword"
style="@style/SignUpEditText"
android:layout_marginTop="@dimen/paddingSmall"
android:hint="@string/password"
android:imeOptions="actionDone"
android:inputType="textPassword"/>
<com.tremend.indieframe.ui.custom_button.IndieButton
android:id="@+id/btLogin"
android:layout_width="@dimen/loginButtonWidth"
android:layout_height="@dimen/loginButtonHeight"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/paddingXXLarge"
android:background="@drawable/round_button_white_shape"
android:text="@string/login"
android:textColor="@color/colorAccent"
android:textSize="@dimen/fsXLarge"
app:font_type="SemiBold" />
</LinearLayout>
在我的片段中,我使用 ButterKnife 绑定视图:
@BindView(R.id.etEmail)
EditText etEmail;
@BindView(R.id.etPassword)
EditText etPassword;
我使用的唯一一行是:
etEmail.getBackground().setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_IN);
etPassword.getBackground().setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_IN);
已修复! 我的 EditText style.xml 中的下面这行搞砸了整个事情。
<item name="android:textSelectHandle">@color/transparent</item>
但是我的弹出菜单仍然有问题 "cropped" :