【问题标题】:Empty space above the app bar应用栏上方的空白区域
【发布时间】:2018-02-26 01:29:04
【问题描述】:

如何去除下图所示的空白空间(水平红线之间的空间)?直到我买了一部新手机(三星 S8),我才在我的应用上看到这个,它的垂直屏幕空间比我的旧 HTC One 大。

该活动的布局文件的开头是:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
<LinearLayout ...

我的价值观-v14/styles.xml 是

<resources>

    <!--
        Base application theme for API 14+. This theme completely replaces
        AppBaseTheme from BOTH res/values/styles.xml and
        res/values-v11/styles.xml on API 14+ devices.
    -->
    <style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- API 14 theme customizations can go here. -->
    </style>

</resources>

我尝试用谷歌搜索这个问题,但找不到任何东西——我一定是在搜索错误的术语。我需要编辑什么文件才能使我的应用操作栏上方的空白区域消失?

编辑:为了比较,这是应用程序在模拟器中的样子(在我的 HTC One 上看起来是一样的):

当我在三星 S8 上运行该应用程序时,我希望该应用程序的行为方式与上述相同(即操作栏上方没有黑色空间)。我需要改变什么?

【问题讨论】:

  • 不是Actionbar吗?我认为主题需要更改为NoActionBar 才能与工具栏一起使用。

标签: android android-layout screen


【解决方案1】:

更改此&lt;style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar"&gt;

 <style name="AppBaseTheme" parent="Theme.AppCompat.Light.NoActionBar">

希望这对您有所帮助,如果没有请发布您的完整 xml 文件

乐于助人

【讨论】:

  • 谢谢,我会试试这个并报告。
  • 使用Theme.AppCompat.Light.NoActionBar 不起作用:它只是导致操作栏(显示“概率谜题”的栏,位于下方红线下方)消失。我希望操作栏上方(两条红线之间)的空白空间消失。你需要看哪个xml文件?
  • 请发布此布局的整个 xml 文件
【解决方案2】:

这是因为三星 Galaxy S8 的宽高比更宽。默认情况下,Android 应用程序支持的最大纵横比为 16:9。要解决此问题,请将此元素添加到清单中的 &lt;application&gt; 标记内:

<meta-data android:name="android.max_aspect" android:value="2.1" />

此 Google 博客文章中提供了完整的详细信息:https://android-developers.googleblog.com/2017/03/update-your-app-to-take-advantage-of.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-05
    • 2021-02-10
    • 2015-03-05
    • 2019-05-04
    • 2019-07-04
    • 1970-01-01
    相关资源
    最近更新 更多