【发布时间】:2019-08-31 08:55:27
【问题描述】:
我想知道使用 Android Studio IDE 组件调色板添加的两个小部件 android.support.v7.widget.CardView 和 Material Design 文档中使用的 com.google.android.material.card.MaterialCardView 之间的区别。
它们是包含相同小部件的两个库吗?我应该使用哪一个以及如何做出这个决定?
我尝试阅读更多developers.android 文档,但是developer.android 上的文档非常大,有很多版本,我有点困惑,无法在所有这些版本之间找到一个好的解释,这一切的历史以及它是如何到达那里的。有人愿意让我了解这段历史吗?
材料设计文档使用:
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content">
</com.google.android.material.card.MaterialCardView>
来源:https://material.io/develop/android/components/material-card-view/
使用 Android Studio 时添加的 CardView XML:
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.CardView>
【问题讨论】:
-
这是材质布局,看起来更干净。
-
那么,是否建议使用 android.support/androidx(我读过,旧支持库的版本)而不是遵循使用 com.google.android.material 的材料指南?
-
不,我也推荐 Material 主题。我只是在解释材料和支持库的不同之处。
-
请注意,
com.google.android.material.card.MaterialCardView扩展了androidx.cardview.widget.CardView。见developer.android.com/reference/com/google/android/material/…
标签: android android-cardview material-components-android material-components cardview