Empty space above the app bar

試著忘記壹切 提交于 2020-01-24 21:49:09

问题


How do I get rid of the empty space shown below (the space between the horizontal red lines)? I didn't see this on my app until getting a new phone (Samsung S8), which has more vertical screen space than my old HTC One.

The beginning of the layout file for that activity is:

<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 ...

My values-v14/styles.xml is

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

I tried googling this problem but I couldn't find anything -- I must be searching for the wrong terms. What file do I need to edit to make the empty space above my app's action bar go away?

Edit: for comparison, here's what the app looks like in the emulator (it looks the same way on my HTC One):

I'd like the app to behave the same way as above (i.e. no black space above the action bar) when I run it on my Samsung S8. What do I need to change?


回答1:


This is happening due to the wider aspect ratio of the Samsung Galaxy S8. By default, Android applications support a maximum aspect ratio of 16:9. To solve, add this element inside the <application> tag in your manifest:

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

Full details available in this Google blog post: https://android-developers.googleblog.com/2017/03/update-your-app-to-take-advantage-of.html




回答2:


change this <style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">

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

hopefully this will help you out , if not Kindly post your full xml file

happy to help



来源:https://stackoverflow.com/questions/48960080/empty-space-above-the-app-bar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!