Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/182.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 5)_Android - Fatal编程技术网

如果水平进度条位于工具栏上方,则不可见(适用于Android 5)

如果水平进度条位于工具栏上方,则不可见(适用于Android 5),android,Android,我试图通过使用以下XML将水平进度条放置在工具栏的顶部 my_activity.xml toolbar.xml 然而,当谈到Android 5+时,工具栏顶部的水平进度条不可见 如果我把线移走 <include layout="@layout/toolbar"/> 我将在Android 5中获得以下屏幕截图+ 顶部进度条似乎被工具栏阻止了?但是,我认为在FrameLayout中,进度条的z顺序比工具栏的高 请问,在Android 5+中,如果将水平进度条放在工具栏上方

我试图通过使用以下XML将水平进度条放置在工具栏的顶部

my_activity.xml

toolbar.xml

然而,当谈到Android 5+时,工具栏顶部的水平进度条不可见

如果我把线移走

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

我将在Android 5中获得以下屏幕截图+

顶部进度条似乎被工具栏阻止了?但是,我认为在
FrameLayout
中,进度条的z顺序比工具栏的高

请问,在Android 5+中,如果将水平进度条放在工具栏上方,如何使其可见?请尝试使用以下方法:

<RelativeLayout
        android:id="@+id/container_toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <include
            android:id="@+id/toolbar"
            layout="@layout/toolbar" />

       // try to set your progress bar here
       // on top of the toolbar

    </RelativeLayout>

//尝试在此处设置进度条
//在工具栏的顶部

在Android 5.0+设备上,在确定组件的z顺序时会考虑到标高-标高较高的组件明显高于标高较低的组件,即使在XML文件中较早声明了标高较高的项目(通常会导致其落后)


您可以将提升添加到
进度条
,与
工具栏
的提升相匹配-这将确保与以前版本的Android相同的z顺序工作。

但是,我不希望进度条占用工具栏的空间。i、 例如,顶部进度条不应“向下推”工具栏。但是,LinearLayout将向下推工具栏。我不想按下工具栏。我想让进度条和工具栏重叠,进度条的z顺序更高。这就是为什么我用RelativeLayout发布文章的原因。如果将进度条放在工具栏顶部,则只需要Visibility.GONE和Visibility.Visibility即可位于工具栏顶部。RelativeLayout不会按下工具栏应该使用什么
RelativeLayout.LayoutParams
?因为我从未遇到过允许堆栈重叠的RelativeLayout。此任务不需要LayoutParams。将进度条放在我的代码示例的注释部分。你想用什么就用什么。为了获得更好的外观,将进度条与匹配宽度和定义的高度放在一起(以确保它不会以任何方式干扰工具栏),这是一个很好的提示!我花了相当长的时间来试验各种技术,比如
bringToFront
,以提高进度条的z顺序。他们失败了。你的建议很管用。非常感谢。
<include layout="@layout/toolbar"/>
<RelativeLayout
        android:id="@+id/container_toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <include
            android:id="@+id/toolbar"
            layout="@layout/toolbar" />

       // try to set your progress bar here
       // on top of the toolbar

    </RelativeLayout>