Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/225.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.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 Layout_Android Toolbar - Fatal编程技术网

Android 如何在工具栏底部获得边框?

Android 如何在工具栏底部获得边框?,android,android-layout,android-toolbar,Android,Android Layout,Android Toolbar,我想在白色工具栏的底部添加一个灰色边框,使其与主要内容明显分开。我正在设置工具栏,如下所示: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_height="wrap_co

我想在白色工具栏的底部添加一个灰色边框,使其与主要内容明显分开。我正在设置工具栏,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:orientation="vertical"
android:id="@+id/pick_root_layout">

<android.support.v7.widget.Toolbar
    android:id="@+id/pick_toolbar"
    android:layout_height="?attr/actionBarSize"
    android:layout_width="match_parent"
    android:minHeight="?attr/actionBarSize"
    app:theme="@style/Toolbar.White"
    android:background="@color/white">
</android.support.v7.widget.Toolbar>

<android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/swipe_refresh_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <ListView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/conversation_list">
  </ListView>

</android.support.v4.widget.SwipeRefreshLayout>

</LinearLayout>


我需要在工具栏底部添加一条小灰线,当我移动时它也会随之滚动。我该怎么做?如果可能的话,我希望避免制作自定义布局。

如果您试图添加一个阴影类型的效果,该效果将保持附着在工具栏上,一个简单的方法是使用FrameLayout包装您的SwipeRefreshLayout,并在FrameLayout上放置前景

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:orientation="vertical"
    android:id="@+id/pick_root_layout">

    <android.support.v7.widget.Toolbar
        android:id="@+id/pick_toolbar"
        android:layout_height="?attr/actionBarSize"
        android:layout_width="match_parent"
        android:minHeight="?attr/actionBarSize"
        app:theme="@style/Toolbar.White"
        android:background="@color/white"/>

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:foreground="@drawable/bottom_shadow">

            <android.support.v4.widget.SwipeRefreshLayout
                android:id="@+id/swipe_refresh_layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <ListView
                     android:layout_width="match_parent"
                     android:layout_height="match_parent"
                     android:id="@+id/conversation_list" />

            </android.support.v4.widget.SwipeRefreshLayout>
        </FrameLayout>
</LinearLayout>


听起来您希望工具栏上有一个下拉阴影类型的效果,当您滚动列表视图时,该效果会一直附着在工具栏上,对吗?