2017-04-26 2 views
0

Ich bin neu in Android App Entwicklung. Ich mache ein Projekt im Android-Studio. Ich möchte eine Liste von cardview auflisten, die rutschen wird. Wenn jemand die Antwort kennt, bitte teilen Sie Ihre Antwort und xml-Code too.My xml-Code ist unterScrolling Cardview funktioniert nicht

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

wo die Scrollview ist? – Rajasekhar

+0

Wo muss ich mich bewerben? –

+0

Warum 3 'CardView's? Verwenden Sie 1 'CardView' in einem' RecyclerView'. Sie werden automatisch scrollen. Überprüfen Sie dieses Tutorial bitte - http://www.android--tutorials.com/2016/03/android-horizontal-recyclerview-example.html – tahsinRupam

Antwort

2

Finden Sie die Lösung

<ScrollView 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:fillViewReport="true"> 

<LinearLayout 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
android:background="@drawable/images" 
tools:context="litifer.awesome.game.cardview.MainActivity"> 
//----------- 
//----------- 

</LinearLayout> 

</ScrollView> 
+1

sollte es android sein: fillViewport = "true" –

+0

Es funktioniert jetzt –

Verwandte Themen