0

I'm writing an application for a project. My question is how can I set shadow beetween the first and the second constraint layout? Should I need to create a xml in drawabale to add to the main one?

I post the xml below and if it is necessary to place the java code also.

<?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:id="@+id/constraintLayout"
        android:layout_width="350dp"
        android:layout_height="310dp"
        android:background="#ff6600">

        <android.support.constraint.ConstraintLayout
            android:layout_width="290dp"
            android:layout_height="266dp"
            android:background="#f2f2f2"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintHorizontal_bias="0.266"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_bias="0.491">

            <TextView
                android:id="@+id/textView"
                android:layout_width="212dp"
                android:layout_height="157dp"
                android:layout_marginStart="8dp"
                android:layout_marginTop="16dp"
                android:layout_marginEnd="8dp"
                android:layout_marginBottom="8dp"
                android:gravity="center"
                android:text="Vuoi registrarti al Torneo?"
                android:textAlignment="center"
                android:textColor="#000"
                android:textSize="20dp"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintVertical_bias="0.105" />

            <Button
                android:id="@+id/Btn_yes"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="8dp"
                android:layout_marginTop="8dp"
                android:layout_marginEnd="8dp"
                android:layout_marginBottom="8dp"
                android:text="SI"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toStartOf="@+id/Btn_No"
                app:layout_constraintHorizontal_bias="0.508"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/textView"
                app:layout_constraintVertical_bias="0.512" />

            <Button
                android:id="@+id/Btn_No"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="8dp"
                android:layout_marginTop="8dp"
                android:layout_marginEnd="8dp"
                android:layout_marginBottom="8dp"
                android:text="NO"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.845"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/textView"
                app:layout_constraintVertical_bias="0.512" />
        </android.support.constraint.ConstraintLayout>
    </android.support.constraint.ConstraintLayout>

Thanks for the answers.

Sandeep Malik
  • 1,972
  • 1
  • 8
  • 17
  • Why not Use a `CardView` ? If this is much complicated than this, You should provide an image of output layout . – ADM Apr 19 '19 at 09:19
  • I have to connect this layout with a dialog. – Gioele.sandrin Apr 19 '19 at 09:25
  • Not helping .. Its pretty much unclear what you want to achieve exactly .. Please add an image or video of output with question . What i understand you can add a view with [Gradient background](https://stackoverflow.com/questions/13929877/how-to-make-gradient-background-in-android) in between two layouts .. – ADM Apr 19 '19 at 09:35

1 Answers1

1

You can use Cardview Like this:

app:cardUseCompactPadding = "true"

Also mention android:hardwareAccelerated="true" in your manifest file

<android.support.v7.widget.CardView
        android:id="@+id/card_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginRight="5dp"
        app:cardBackgroundColor="@color/colorprimary"
        app:cardCornerRadius="5dp"
        app:cardUseCompatPadding="true"
        app:elevation="0dp">
    </android.support.v7.widget.CardView>
Mayur
  • 735
  • 4
  • 14