Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/230.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android:工具栏立面/阴影_Android_Android Toolbar - Fatal编程技术网

Android:工具栏立面/阴影

Android:工具栏立面/阴影,android,android-toolbar,Android,Android Toolbar,我想知道为什么只有NestedScrollView存在时,这个工具栏才会产生阴影(我从互联网上得到了这个例子) 此工具栏(不带NestedScrollView)不投射任何阴影: <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/ap

我想知道为什么只有NestedScrollView存在时,这个工具栏才会产生阴影(我从互联网上得到了这个例子)


此工具栏(不带NestedScrollView)不投射任何阴影:

<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:layout_height="wrap_content"
        android:layout_width="match_parent">

        <android.support.v7.widget.Toolbar
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:local="http://schemas.android.com/apk/res-auto"
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:minHeight="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            local:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            />
    </android.support.design.widget.AppBarLayout>

</android.support.design.widget.CoordinatorLayout>

如果需要的话,我可以上传照片,但我不知道为什么会这样。 这就是我迄今为止所尝试的:

  • 在父线性布局上设置clipToPadding=“false”
  • 手动设置标高(我的设备不是预棒棒糖)
  • 在视图上设置outlineProvider=“bounds”
  • 在AndroidManifest.xml上设置android:hardwareAccelerated=“true”

编辑:我用标签解决了这个问题。用代码检查我的答案。

再仔细研究一下,我发现合并标签就可以了。此标记可以将toolbar.xml合并到父布局中,父布局将负责z顺序,并将工具栏放置在我想要的位置

<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:layout_height="wrap_content"
        android:layout_width="match_parent">

        <android.support.v7.widget.Toolbar
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:local="http://schemas.android.com/apk/res-auto"
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:minHeight="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            local:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            />
    </android.support.design.widget.AppBarLayout>

</android.support.design.widget.CoordinatorLayout>
</merge>


不,在这里问不是我做的第一件事,只是运气好,在我发布后不到一个小时就找到了这个标签。无论如何,这是我的解决方案。

请发布您想要实现的图片以及您的代码所获得的内容。我会帮你的。@AmrishKakadiya读了我的回复,我已经设法修复了它,但我仍然可以发布图片。谢谢你的帮助:DGreat,不需要上传图片。
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:layout_height="wrap_content"
        android:layout_width="match_parent">

        <android.support.v7.widget.Toolbar
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:local="http://schemas.android.com/apk/res-auto"
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:minHeight="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            local:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            local:popupTheme="@style/ThemeOverlay.AppCompat.Light"
            />
    </android.support.design.widget.AppBarLayout>

</android.support.design.widget.CoordinatorLayout>
</merge>