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

时间:2019-12-05 15:24:35

标签: android android-layout xamarin.android android-softkeyboard

点击以关闭虚拟键盘时,该位置上显示白色背景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>

1 个答案:

答案 0 :(得分:0)

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