隐形PopupWindow延迟键盘辅助功能(EditText)

时间:2018-04-06 07:21:43

标签: android android-edittext android-softkeyboard

有没有人理解为什么当我点击一个非空的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来自哪里以及为什么只有当Logcat不为空时才会在EditText中触发。

PS:我也注意到当我长按EditText打开弹出菜单(复制/粘贴/等)时,菜单有一个奇怪的边距/填充和文本没有居中。

这里是代码:

<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);

1 个答案:

答案 0 :(得分:0)

固定! 我的EditText style.xml里面的下面一行搞砸了整个事情。

<item name="android:textSelectHandle">@color/transparent</item>

但我仍然遇到弹出菜单的问题,即#34;裁剪&#34; :