在 Xamarin (Visual Studio) for Android 中刷卡,就像地图/新闻中的 Google C



下面是我的应用程序布局,我已经包含了卡片视图。但无法让它像地图/新闻中的谷歌卡一样刷卡。

    <?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>

我需要在每次刷卡时加载不同的数据。刷卡是可逆的,不像屏幕的简单触摸事件。
当我从左到右或从右到左滑动卡时,下一张卡应该是可见的。我还在xamarin论坛上检查了解决方案,并发现了仅适用于IOS的xcardview。

我在Xamarin论坛上找到了解决方案。实际上,我正在尝试实现类似于ViewPager和Carousel View的功能。以下是在ViewPager上讨论的链接。

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

下面是 Cheesebaron 在 Git 上非常好的示例代码https://github.com/Cheesebaron/ViewPagerIndicator

最新更新