1

I try to do card view but i can't understand how to do a scrolling page with textview and a webview. Can someone show me the basic code of Card View.

<TextView
            android:id="@+id/textView4"
            android:layout_width="432dp"
            android:layout_height="510dp"
            android:text="TextView" />

        <WebView
            android:id="@+id/webview"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

I want that the page of my app that his a text view and a webview that the user can scroll. So I think that I can do that with cardview, but I can't understand the code of cardview that I saw on videos. How can I use this function with only a textview and a cardview?

I have looked some videos on CardView but I can't used their code for what I want to do. Me I have only a text view and a webview that I want that the user can scroll. Would someone show some basic code of card view, and explain what it does?

2
  • please make your question more clear. add some codes or examples or UI to understand what you are actually trying to achieve Oct 23, 2019 at 10:50
  • thanks i did it in the rush I'm sorry.
    – user12246644
    Oct 23, 2019 at 11:11

1 Answer 1

2

Add the card view dependencies

   dependencies {
            implementation 'androidx.cardview:cardview:1.0.0'
   }

Add the cardview in your layout

<androidx.cardview.widget.CardView
        android:id="@+id/card_view"
        xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        card_view:cardBackgroundColor="@color/grey_300"
        card_view:cardCornerRadius="10dp"
        card_view:cardElevation="5dp"
        card_view:cardUseCompatPadding="true">
<TextView
            android:id="@+id/textView4"
            android:layout_width="432dp"
            android:layout_height="510dp"
            android:text="TextView" />

        <WebView
            android:id="@+id/webview"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
</<androidx.cardview.widget.CardView>
7
  • when i compile i have this error The project 'info' may be using a version of Gradle that does not contain the method. Open Gradle wrapper file but thanks for helping but i saw on video that there his a java code do we need to put it or not?
    – user12246644
    Oct 23, 2019 at 11:12
  • in what dependencies i need to put the compile code module app or Project info
    – user12246644
    Oct 23, 2019 at 11:16
  • Inside the app dependencies
    – Malavan
    Oct 23, 2019 at 11:22
  • cardview-v7:21.0.0-rc1 Really?? There are the v28.0.0, the androidx version and the material components version, but pls not a very very old RC. Oct 23, 2019 at 11:44
  • thanks to help me i will let you know if i have any diffuclties
    – user12246644
    Oct 23, 2019 at 11:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.