Java 什么';我工具栏后面的这个奇怪的白色矩形是什么?

Java 什么';我工具栏后面的这个奇怪的白色矩形是什么?,java,android,android-layout,android-toolbar,material-components,Java,Android,Android Layout,Android Toolbar,Material Components,我一整天都在试图摆脱它,但都没有用。尝试给它周围的每个视图和布局一个不可见的背景色。还尝试减小布局和视图的大小。那些尖锐的白色边缘依然存在。它们是什么?这是文本填充,网站上说代码太多,文本太少。“嗨,文本填充器,你还好吗?” 活动\u main.xml: <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout

我一整天都在试图摆脱它,但都没有用。尝试给它周围的每个视图和布局一个不可见的背景色。还尝试减小布局和视图的大小。那些尖锐的白色边缘依然存在。它们是什么?这是文本填充,网站上说代码太多,文本太少。“嗨,文本填充器,你还好吗?”

  • 活动\u main.xml:

    <?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">
    <include
        android:id="@+id/mainToolbar"
        layout="@layout/toolbar"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
    
    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/mainToolbar">
    
        <com.google.android.material.appbar.AppBarLayout
            android:id="@+id/tab_anim_appbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center|top"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:background="#00FFFFFF">
    
            <com.google.android.material.appbar.MaterialToolbar
                android:id="@+id/searchToolbar"
                style="@style/Widget.MaterialComponents.Toolbar.Primary"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center|top"
                android:background="#A106A1"
                android:elevation="2dp"
                app:contentInsetLeft="0dp"
                app:contentInsetStart="0dp"
                app:layout_scrollFlags="scroll|enterAlways">
    
                <!-- dummy to catch focus -->
                <LinearLayout
                    android:layout_width="0px"
                    android:layout_height="0px"
                    android:focusable="true"
                    android:focusableInTouchMode="true" />
    
                <androidx.appcompat.widget.SearchView
                    android:id="@+id/searchView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:animateLayoutChanges="true"
                    android:layoutDirection="rtl"
                    app:iconifiedByDefault="true"
                    android:layout_marginLeft="30dp"
                    android:layout_marginRight="30dp"/>
    
            </com.google.android.material.appbar.MaterialToolbar>
    
        </com.google.android.material.appbar.AppBarLayout>
    
        <include layout="@layout/content_scrolling"/>
    
    </androidx.coordinatorlayout.widget.CoordinatorLayout>
    
    </androidx.constraintlayout.widget.ConstraintLayout>
    

它是
AppBarLayout
的阴影。使用:

<com.google.android.material.appbar.AppBarLayout
    app:elevation="0dp"
    android:background="@android:color/transparent"

它是
AppBarLayout
的阴影。使用:

<com.google.android.material.appbar.AppBarLayout
    app:elevation="0dp"
    android:background="@android:color/transparent"

如果您使用的是最新的Android Studio,其中包含一个很棒的工具,名为
Layout Inspector
,您可以使用它来调试类似的东西。它显示根视图中的所有层和视图(它以前在那里出现过,只是没有那么复杂)。详细信息如下:您在“材质”工具栏上使用圆角,但阴影不是圆角。移除标高应固定it@PrimožIvančič显然罪犯不是AppBarLayout就是TooBar本身。我被难住了。@MervinHemaraju我试着删除了
android:elevation=“2dp”
。如果你使用的是最新的Android Studio,其中有一个很棒的工具,名为
布局检查器
,你可以用它来调试类似的东西。它显示根视图中的所有层和视图(它以前在那里出现过,只是没有那么复杂)。详细信息如下:您在“材质”工具栏上使用圆角,但阴影不是圆角。移除标高应固定it@PrimožIvančič显然罪犯不是AppBarLayout就是TooBar本身。我被难住了。@MervinHemaraju我试着删除了
android:elevation=“2dp”
。这没什么区别。