簡體   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