首页 > 解决方案 > 在 AVD Manager 的小屏幕上,屏幕顶部变得太大

问题描述

当我在 AVD 管理器中使用小屏幕时,屏幕顶部变得太大。在更大的屏幕上这是正常的。(它是工具栏上方的小线)对于activity-main和content-main中的布局,我使用了“match-parent”你知道那里发生了什么以及如何修复它吗?

非常感谢法比安

小屏幕

大屏幕

这是我在 content_main 中的代码:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
tools:showIn="@layout/activity_main">
</androidx.constraintlayout.widget.ConstraintLayout>

这是我的activity_main:

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<com.google.android.material.appbar.AppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:theme="@style/AppTheme.AppBarOverlay">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="?attr/colorPrimary"
        app:popupTheme="@style/AppTheme.PopupOverlay" />

</com.google.android.material.appbar.AppBarLayout>

<include layout="@layout/content_main" />

<io.github.yavski.fabspeeddial.FabSpeedDial
   android:id="@+id/addButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_margin="@dimen/fab_margin"
    android:src="@drawable/ic_add_white_24dp"
    app:fabGravity="bottom_end"
    app:fabMenu="@menu/menu2">


</io.github.yavski.fabspeeddial.FabSpeedDial>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

我刚刚发现没有应用程序的屏幕也是这样的。可能是 AVD 管理器的问题,而不是代码的问题。

关闭应用程序的小屏幕

关闭应用程序的大屏幕

标签: androidandroid-studiolayoutscreen-sizeavd-manager

解决方案


推荐阅读