How can I show the shadow only on the bottom side of the tablayout?
Asked Answered
B

0

1

I have this layout :

    <?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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#ffffff"
    android:clickable="true"
    android:focusable="true">


    <android.support.constraint.ConstraintLayout
        android:id="@+id/details"
        android:layout_width="500dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="32dp"
        android:background="@color/grayEB"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toStartOf="@+id/shutdownButton"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.007">

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="8dp"
            android:layout_marginTop="8dp"
            android:text="Flusso autorizzativo"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <TextView
            android:id="@+id/textView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="8dp"
            android:layout_marginTop="8dp"
            android:text="--"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/textView2" />

        <TextView
            android:id="@+id/textView4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="8dp"
            android:layout_marginEnd="8dp"
            android:text="Totale cliente"
            app:layout_constraintBaseline_toBaselineOf="@+id/textView2"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.274"
            app:layout_constraintStart_toEndOf="@+id/textView2" />

        <TextView
            android:id="@+id/textView5"
            android:layout_width="wrap_content"
            android:layout_height="15dp"
            android:layout_marginStart="8dp"
            android:layout_marginTop="12dp"
            android:layout_marginEnd="8dp"
            android:layout_marginBottom="8dp"
            android:text="Spesa PRE: € --"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toStartOf="@+id/textView6"
            app:layout_constraintHorizontal_bias="0.959"
            app:layout_constraintStart_toEndOf="@+id/textView3"
            app:layout_constraintTop_toBottomOf="@+id/textView4"
            app:layout_constraintVertical_bias="0.0" />

        <TextView
            android:id="@+id/textView6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="60dp"
            android:text="Spesa stimata: € --"
            app:layout_constraintBaseline_toBaselineOf="@+id/textView5"
            app:layout_constraintEnd_toEndOf="parent" />
    </android.support.constraint.ConstraintLayout>

    <Button
        android:id="@+id/shutdownButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        android:layout_marginEnd="8dp"
        android:text="ShutDown !!!"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <android.support.v4.view.ViewPager
        android:id="@+id/frameLayout2"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginBottom="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/MyTabs">

    </android.support.v4.view.ViewPager>

    <android.support.design.widget.TabLayout
        android:id="@+id/MyTabs"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp"
        android:padding="0dp"
        android:elevation="4dp"
        android:paddingBottom="4dp"
        app:tabGravity="center"
        app:tabMode="scrollable"
        app:layout_constraintBottom_toTopOf="@+id/frameLayout2"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/details"
        app:layout_constraintVertical_chainStyle="packed"
        android:background="#ffff"/>




</android.support.constraint.ConstraintLayout>

I have set the elevation and paddingBottom of MyTabs to show the shadow under the tablayout, but in this way the shadown is showed not only on the bottom side but on each side.

I have to show the shadow only on the bottom side, what I have to do ?

OT : this layout is also too slow to be rendered

Bookseller answered 14/1, 2019 at 0:58 Comment(6)
paste full xml file pleaseLiverpudlian
I have just edited the question :) Thanks !Bookseller
try this <android.support.design.widget.TabLayout android:id="@+id/MyTabs" android:layout_width="0dp" android:layout_height="wrap_content" android:elevation="10dp" app:tabGravity="center" app:tabMode="scrollable" app:layout_constraintBottom_toTopOf="@+id/frameLayout2" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" android:background="#ffff"/>Liverpudlian
it doesn't works, in this way the shadow is on top and bottom sideBookseller
try this link #34676291Liverpudlian
Thanks. I have create a custom drawable with gradient and I put it on the bottom side of the tablayout ;)Bookseller

© 2022 - 2024 — McMap. All rights reserved.