如何删除LinearLayout阴影?

时间:2018-09-06 23:29:00

标签: android android-actionbar android-linearlayout

我的布局如下:

enter image description here

XML代码:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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=".Activities.OwnerProfileActivity">

    <LinearLayout
        android:id="@+id/linear_layout_profile_top"
        android:layout_width="0dp"
        android:layout_height="165dp"
        android:background="@color/colorPrimary"
        android:orientation="vertical"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <View
            android:layout_width="match_parent"
            android:layout_height="20dp" />

        <ImageView
            android:id="@+id/imageView_profile_picture"
            style="@style/ProfileImageStyle"
            android:layout_height="wrap_content"
            app:srcCompat="@drawable/ic_user" />

        <TextView
            android:id="@+id/textView_user_name"
            style="@style/UserNameLabelStyle"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="TextView"
            android:textSize="18sp" />
    </LinearLayout>

    <android.support.design.widget.TabLayout
        android:id="@+id/tabLayout"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/linear_layout_profile_top"
        app:tabSelectedTextColor="@color/colorPrimary">

        <android.support.design.widget.TabItem
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/about_label" />

        <android.support.design.widget.TabItem
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/businesses_label" />

        <android.support.design.widget.TabItem
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/coupons_label" />

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

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager_page"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toTopOf="@+id/lower_navigation"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/tabLayout"
        app:layout_constraintVertical_bias="1.0" />

    <fragment
        android:id="@+id/lower_navigation"
        android:name="com.nprogramming.android.couponsapp.Fragments.LowerNavigationBarFragment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent" />
</android.support.constraint.ConstraintLayout>

如何消除ActionBar和LinearLayout(红色块)之间的阴影?

谢谢。

1 个答案:

答案 0 :(得分:1)

将此代码添加到onCreate()的方法OwnerProfileActivity中。

if(getSupportActionBar() != null) { getSupportActionBar().setElevation(0); }