【问题标题】:How to get rid of white strip at the top of the screen with adjustResize如何使用adjustResize去除屏幕顶部的白条
【发布时间】:2016-08-20 08:17:41
【问题描述】:

当键盘打开时,屏幕顶部会出现一条白色条带,无论键盘状态如何变化,它都会持续存在。

如果我使用adjustPan,那么它可以工作,但是,我只想使用adjustResize

这是问题的图片:


我在 AndroidManifest.xml 中的活动声明

<activity
    android:name=".MainActivity"
    android:screenOrientation="portrait"
    android:theme="@style/MyTheme"
    android:windowSoftInputMode="adjustResize"/>

<style name="MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:windowDrawsSystemBarBackgrounds" 
          tools:targetApi="lollipop">false</item>
</style>

【问题讨论】:

  • 你在使用 weightsum 吗?
  • 请放一些相关的代码:工具栏或MainActivity xml
  • 显示你的 xml 文件
  • 只需从您的主题中删除 windowDrawsSystemBarBackgrounds,您为什么要添加它?!
  • pre lollipop 不支持更改状态栏颜色,因此如果您在代码中的某处更改它,请将其删除。目前这不是一个好主意。

标签: android android-layout


【解决方案1】:

KitKat 中有一种称为Immersive Full-Screen 模式的技术。我认为它现在是实现全屏 Activity 的首选方式。

这是来自文档的example

【讨论】:

    【解决方案2】:

    从 Activity 的布局文件中移除此白色条带。只要您不提供布局 xml,我就不能多说。

    我建议您使用Hierarchy Viewer 进行布局调试。

    【讨论】:

    • 我已经提到了>>当键盘打开时,屏幕顶部会出现一个白色条带
    • @Hits 只要您不向我们展示布局 xml 文件,就很难对您的问题给出更准确的答案。
    • @Hits 查找 android:paddingTop 属性并将其删除。
    猜你喜欢
    • 1970-01-01
    • 2023-02-26
    • 1970-01-01
    • 2010-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多