滚动cardview无法正常工作

时间:2017-04-26 08:17:45

标签: android android-linearlayout android-cardview

我是Android应用开发的新手。我正在android-studio中创建一个项目。我想列出将要滑动的cardview。如果有人知道答案,请分享你的答案和xml代码。我的xml代码在下面

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
android:background="@drawable/images"
tools:context="litifer.awesome.game.cardview.MainActivity"
app:layout_behavior="@string/appbar_scrolling_view_behavior">

<android.support.v7.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/cardView1"
    android:layout_gravity="center"
    android:layout_marginTop="20dp"
    android:layout_marginLeft="20dp"
    android:layout_marginRight="20dp"
    app:cardCornerRadius="5dp"
    app:cardElevation="5dp"
    android:clickable="true"
    >
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/cardView1Text"
        android:text="Get in Touch"
        android:textSize="20dp"
        android:paddingTop="40dp"
        />
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/cardView1Edit"
        android:hint="Enter Email here"
        />
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/cardView1Button"
        android:text="Submit"
        android:layout_gravity="center" />
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingBottom="40dp"/>
    </LinearLayout>
</android.support.v7.widget.CardView>

<android.support.v7.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="10dp"
    android:id="@+id/cardView2"
    android:layout_gravity="center"
    android:layout_marginLeft="20dp"
    android:layout_marginRight="20dp"
    app:cardCornerRadius="5dp"
    app:cardElevation="5dp"
    android:clickable="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/cardView2Text"
            android:text="Bluetooth demo"
            android:textSize="20dp"
            android:paddingTop="20dp"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/cardView1Text1"
            android:text="Send Notification when in Bluetooth range"
            android:textSize="20dp"
            android:clickable="true"
            android:paddingBottom="40dp"/>
    </LinearLayout>
</android.support.v7.widget.CardView>

<android.support.v7.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="10dp"
    android:id="@+id/cardView3"
    android:layout_gravity="center"
    android:layout_marginLeft="20dp"
    android:layout_marginRight="20dp"
    app:cardCornerRadius="5dp"
    app:cardElevation="5dp"
    android:clickable="true"
    android:paddingTop="40dp"
    android:paddingBottom="40dp">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/cardView3Text"
            android:text="Wifi Demo"
            android:textSize="20dp"
            android:paddingTop="40dp"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/cardView3Text1"
            android:text="Send Notification when in Wifi range"
            android:textSize="20dp"
            android:paddingBottom="40dp"/>
    </LinearLayout>
</android.support.v7.widget.CardView>

<android.support.v7.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/cardView4"
    android:layout_marginTop="10dp"
    android:layout_marginLeft="20dp"
    android:layout_marginRight="20dp"
    app:cardCornerRadius="5dp"
    app:cardElevation="5dp"
    android:layout_gravity="center"
    android:clickable="true"
    android:paddingTop="40dp"
    android:paddingBottom="40dp"
    >
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/cardView4Text"
            android:text="Review Demo"
            android:textSize="20dp"
            android:paddingTop="40dp"/>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/cardView4Text1"
            android:text="Get Customer Reviews using beacons"
            android:textSize="20dp"
            android:paddingBottom="40dp"/>
    </LinearLayout>

</android.support.v7.widget.CardView></LinearLayout>

1 个答案:

答案 0 :(得分:2)

找到解决方案

<div>