swiping card in xamarin (visual studio) for android like google cards in maps/news

847 views Asked by At

Below is my application layout and I've already included card view. But unable to make it swiping card like google cards in maps/news.

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="8dp">
        <android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
            android:id="@+id/card_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            card_view:cardCornerRadius="8dp"
            android:elevation="2dp"
            card_view:cardBackgroundColor="@color/orange">
            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:background="@color/white"
                android:id="@+id/contenLayout">
                <ImageView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:id="@+id/imgSource"
                    android:layout_centerInParent="true"
                    android:scaleType="fitXY"
                    android:src="@drawable/image" />
                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:id="@+id/mytextview"
                    android:textSize="20sp"
                    android:layout_alignParentBottom="true"
                    android:textColor="@color/content"
                    android:background="@color/orange"
                    android:gravity="center_horizontal"
                    android:paddingBottom="5dp"
                    android:paddingTop="5dp"/>
            </RelativeLayout>
        </android.support.v7.widget.CardView>
    </LinearLayout>

I need to load different data in each card swipe. Card swipes are reversible unlike simple touch event of screen.
Next card should be visible, when I'm swiping the card from left to right or right to left. I also checked for solution on xamarin forum and found xcardview which is only available for IOS.

1

There are 1 answers

0
iamguni On BEST ANSWER

I found the solution on Xamarin Forum. Actually I was trying to achieve the functionality similar to ViewPager and Carousel View. Below is the link for discussion on ViewPager.

https://forums.xamarin.com/discussion/3174/viewpager-example-with-android-4-0

Below is the very nice sample code by Cheesebaron on Git https://github.com/Cheesebaron/ViewPagerIndicator