Alon Shlider
Alon Shlider

Reputation: 1318

How to make custom layout go ontop of Linearlayout?

I will firstly show the image of my problem -

enter image description here

I have the following XML file -

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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"
    android:background="@color/grey_200">

    <include
        android:id="@+id/include2"
        layout="@layout/toolbar"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <com.etiennelawlor.tinderstack.ui.TinderStackLayout
        android:id="@+id/activity_main_tinder_stack_layout"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/include2" />


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:orientation="horizontal"
        android:padding="5dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent">

        <Button
            android:id="@+id/activity_main_pass_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:background="#A9A9A9"
            android:tag="2"
            android:text="@string/activity_main_pass" />

        <Button
            android:id="@+id/activity_main_approve_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:background="#98FB98"
            android:tag="3"
            android:text="@string/activity_main_approve" />

        <Button
            android:id="@+id/activity_main_delete_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:background="#ff0000"
            android:tag="1"
            android:text="@string/activity_main_delete"
            tools:layout_editor_absoluteX="0dp"
            tools:layout_editor_absoluteY="326dp" />
    </LinearLayout>



</androidx.constraintlayout.widget.ConstraintLayout>


I want each card inside my TinderStackLayout, when touched and moved, to move above and hide the linear layout buttons. How can I achieve this behaviour? What I want to achieve is a "tinder like" feeling where the cards feel the entire screen and can be moved freely to where the user wants, without any visual interferes. Reference to what I want to achieve -

enter image description here

Upvotes: 0

Views: 51

Answers (1)

SebastienRieu
SebastienRieu

Reputation: 1512

try adding an elevation to you TinderSlackLayout

Upvotes: 2

Related Questions