What is the difference between card_view and app:card?

Viewed 9

I am implementing CardView in my app and I have notice that it is working without creating a card_view using only "app:" ->

What is the difference between A and B?

A:

<androidx.cardview.widget.CardView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:cardBackgroundColor="@color/white"
            app:cardCornerRadius="10dp"
            >

B:

<androidx.cardview.widget.CardView
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:card_view="http://schemas.android.com/apk/res-auto"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            card_view:cardBackgroundColor="@color/white"
            card_view:cardCornerRadius="10dp"
            >
1 Answers

Generally, there is no important difference. Both app and card_view are namespace declarations, and both use the same namespace: xmlns:card_view="http://schemas.android.com/apk/res-auto". It's worth to mention that in A case you import the app namespace earlier in XML declaration and in case B you import it right in CardView tag

Related