0

In my HomeFragment, I want to add a Card at the center of my activity ( an ImageView ) which receives the value of a Uri stored in Firebase Database. That is working perfectly right now. My main idea is to have an infinite swipeable ImageViews, for example, like Tinder. I've seen a lot of GitHub projects but I am a noob in android development and I can't seem to find a solution to my problem. Can anyone help me in a detailed way I can I achieve this? Here is my idea (this is from this Github Project that had exactly what I wanted, I followed the steps in the guide but I had no success):

Click this link to see the gif, please

This is my layout currently (I know, it has nothing to do what I want to do make right now but this was the only thing I could make. Forget the Horizontal Scroll View and the 3 ImageViews, I want just to show one!)

 <HorizontalScrollView
    android:id="@+id/scrlVPrincipal2"
    android:layout_width="545dp"
    android:layout_height="414dp"
    android:layout_alignParentBottom="true"
    android:layout_alignParentStart="true"
    android:layout_marginTop="32dp"
    android:scrollbars="none"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/txtHomeDesc"
    app:layout_constraintVertical_bias="0.42"
    tools:ignore="MissingConstraints"
    tools:layout_editor_absoluteX="0dp">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        android:paddingRight="1000dp">


        <RelativeLayout
            android:layout_width="1066dp"
            android:layout_height="match_parent">


            <ImageView
                android:id="@+id/imgCard1"
                android:layout_width="259dp"
                android:layout_height="390dp"
                android:layout_alignParentStart="true"
                android:layout_centerVertical="true"
                android:layout_marginStart="13dp"
                android:layout_weight="1"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.504"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintVertical_bias="0.801" />

            <ImageView
                android:id="@+id/imgCard3"
                android:layout_width="259dp"
                android:layout_height="390dp"
                android:layout_alignParentEnd="true"
                android:layout_centerVertical="true"
                android:layout_marginEnd="221dp"
                android:layout_weight="1"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.504"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintVertical_bias="0.801" />

            <TextView
                android:id="@+id/txtPaisNome"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_alignParentStart="true"
                android:layout_gravity="bottom"
                android:layout_marginBottom="25dp"
                android:layout_marginStart="27dp"
                android:text="TextView"
                android:textAlignment="center"
                android:textColor="@color/colorWhite"
                android:textSize="25dp" />

            <ImageView
                android:id="@+id/imgCard2"
                android:layout_width="259dp"
                android:layout_height="390dp"
                android:layout_alignParentStart="true"
                android:layout_centerVertical="true"
                android:layout_gravity="right"
                android:layout_marginStart="298dp"
                android:layout_weight="1"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.504"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintVertical_bias="0.801" />

        </RelativeLayout>
    </FrameLayout>

</HorizontalScrollView> -->
André
  • 25
  • 9
  • If the library you mentioned in your question solves your requirements, why haven't you used it? I don't see `link.fls.swipestack.SwipeStack` in your XML. Do you want to achieve the feature without libraries? – Abhi Jun 05 '18 at 10:57
  • No, I've tried using that library... The problem is that `swipeStack.setAdapter(new SwipeStackAdapter(mData));` I don't know what to put in the mData. I'm newbie in android. If I put the `link.fls.swipestack.SwipeStack` in my XML, do I put the imageView inside it? – André Jun 05 '18 at 11:00
  • check this example https://blog.mindorks.com/android-tinder-swipe-view-example-3eca9b0d4794 – sunil kushwah Jun 05 '18 at 11:01
  • Ahah i've checked probably every single one of them but I still can't understand them... All of them talk about adaptors... I just need the simplest one or someone who explains step by step xD – André Jun 05 '18 at 11:06
  • The SwipeStack library works like a ListView. Therefore you must make an adapter class which holds the data and creates the views for the stack. You can refer to [tutorials](http://www.devexchanges.info/2016/11/cards-stack-like-tinder-application-in.html?m=1) available or refer docs. Stack overflow doesn't provide tutorials. Instead if you have a specific doubt or error, post it as an edit to the question. – Abhi Jun 05 '18 at 11:13
  • So, basically, the first thing that I have to do is replace my `Horizontal Scroll View` with the `link.fls.swipestack.SwipeStack` and leave both Frame Layout and Relative Layout inside it? – André Jun 05 '18 at 11:16
  • Yes. Also refer the tutorial linked in the last comment. – Abhi Jun 05 '18 at 11:18
  • Thanks! I'm referring to it. Where do I put my own images in the ImageViews? – André Jun 05 '18 at 11:31
  • @Abhi I've got a ton of errors https://pastebin.com/unnSGbLW ahaha – André Jun 05 '18 at 11:42
  • You have a simple NullPointerException. [See this](https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it). Follow the tutorial carefully. Also I would also recommend you start learning Android from scratch. – Abhi Jun 05 '18 at 12:01
  • I know, I want to do that but right now I was challenged to make an Android app in few time... I can't find where that null exception comes from... I mean, there are a ton of lines mentioned in the pastebin I sent you – André Jun 05 '18 at 12:25

0 Answers0