如何在添加边距后删除工具栏周围的额外边框?

时间:2017-08-27 05:58:35

标签: android material-design android-toolbar

我在我的布局顶部添加了一个工具栏,但在为它设置边距后,我的工具栏周围会出现一些额外的边框,我认为这是因为ActionBar的属性。我想删除这些额外的边框,但我不知道该怎么做。我现在应该怎么做?提前谢谢你:)

截图:

enter image description here

这是我的XML代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="realup.ir.teacher.Activity.Main"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/realupbackground_co">

    <android.support.design.widget.CoordinatorLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/header">

        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/app_bar_head">

            <android.support.v7.widget.Toolbar
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="#edeaed"
                android:titleTextColor="#89798a"
                android:id="@+id/toolbar"
                app:layout_scrollFlags="scroll|enterAlways"
                android:layout_margin="@dimen/normal_margin"/>

            <android.support.design.widget.CollapsingToolbarLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:layout_scrollFlags="scroll|exitUntilCollapsed"
                android:id="@+id/collapse_toolbar"
                app:titleEnabled="true">


                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:adjustViewBounds="true"
                    android:scaleType="centerCrop"
                    android:src="@drawable/course_page_cover"
                    android:id="@+id/header_image" />


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

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

        <android.support.v4.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">

            <android.support.v7.widget.RecyclerView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/recycle"/>

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

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

</RelativeLayout>

这是工具栏的Java代码:

Toolbar toolbar = (Toolbar) rootView.findViewById(R.id.toolbar);
    ((AppCompatActivity)getActivity()).setSupportActionBar(toolbar);
    toolbar.setTitle("Real Up");
 toolbar.setTitleTextColor(getResources().getColor(R.color.TitlColor,null));

1 个答案:

答案 0 :(得分:0)

检查此答案:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/test/[A-Za-z][0-9]{0,5}$ /test/short.php?url=$1