繁体   English   中英

Android 键盘关闭时 1 秒内显示白色背景

[英]White background shows during 1 sec when keyboard closes on Android

当我点击关闭虚拟键盘时,那个地方会显示白色背景 1 秒钟。

我使用Activity(WindowSoftInputMode = SoftInput.AdjustResize)将“完成”按钮推到虚拟键盘上方,但看到的是白色背景。

如果我使用Activity(WindowSoftInputMode = SoftInput.AdjustPan)没有白色背景,但上面没有“完成”按钮。

如何使用 AdjustResize 修复白色背景?

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/itemsRecyclerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <Button
        android:id="@+id/doneButton"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:visibility="gone" />

</LinearLayout>

主题:

  <style name="AppTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="colorPrimary">#f2f2f2</item>
    <item name="colorPrimaryDark">#f2f2f2</item>
    <item name="colorAccent">#f2f2f2</item>
    <item name="colorControlHighlight">@color/blue</item>

  </style>

  <style name="AppTheme" parent="AppTheme.Base">
    <item name="android:windowContentTransitions">true</item>
    <item name="android:windowAllowEnterTransitionOverlap">true</item>
    <item name="android:windowAllowReturnTransitionOverlap">true</item>
    <item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
    <item name="android:windowSharedElementExitTransition">@android:transition/move</item>
    <item name="colorAccent">#979797</item>
  </style>

我使用下面的代码解决了这个问题: FindViewById(Android.Resource.Id.Content).RootView.SetBackgroundColor(Color.Transparent);

我知道这是一个老问题,但我的做法是将 android:windowBackground 设置为正确的颜色:

   <item name="android:windowBackground">@color/black</item>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM