Search code examples
androidandroid-actionbarandroid-linearlayout

How to remove LinearLayout shadowing?


I have the following layout:

enter image description here

XML Code:

<?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>

How to remove the shadowing between the ActionBar and the LinearLayout (red block)?

Thanks in advance.


Solution

  • Add this code to your method onCreate()of OwnerProfileActivity.

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