Scrollabe cardView Activity

Hey everybody,
I want to display CardViews in my Android App. So i've created a CardView in my Main.axml file...Everything great, the code works! ;)
But if i display more than 2 CardViews the third one wont be displayed because the screen is to small. And that is the problem.
Can I display a scrollable CardView activity? I've saw the recyclerView but didnt understand :(
Can someone help and explain me how to use recyclerView or another way to solve the problem?

Answers

  • VIVEKNEGIVIVEKNEGI USMember ✭✭✭

    just place your all cardview inside ScrollView




  • JonasPTFLJonasPTFL Member ✭✭
    edited April 2018
    But then the App crashes :#
  • VIVEKNEGIVIVEKNEGI USMember ✭✭✭

    @JonasPTFL could you just paste your code here.

  • JonasPTFLJonasPTFL Member ✭✭
    <ScrollView>    
    <android.support.v7.widget.CardView
                    android:layout_width="fill_parent"
                    android:layout_height="130dp"
                    android:layout_gravity="center_horizontal">
                    <LinearLayout
                        android:layout_width="fill_parent"
                        android:layout_height="240dp"
                        android:orientation="vertical"
                        android:padding="8dp"
                        android:id="@+id/cardView1">
                        <TextView
                            android:text="bla bla Konzert"
                            android:textAppearance="?android:attr/textAppearanceLarge"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:id="@+id/textView5" />
                        <TextView
                            android:text="14.07.2018"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:id="@+id/textView2" />
                        <TextView
                            android:text="17:00 bis 21:00 Uhr"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:id="@+id/textView3" />
                        <TextView
                            android:text="Blumensaal, Musterstadt"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:id="@+id/textView4" />
                        <ToggleButton
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:id="@+id/toggleButton1"
                            android:textOn="Angemeldet"
                            android:textOff="Abgemeldet" />
                    </LinearLayout>
                </android.support.v7.widget.CardView>
    <ScrollView>
    
Sign In or Register to comment.