【问题标题】:Using Material Design Components in Android Studio在 Android Studio 中使用 Material Design 组件
【发布时间】:2016-08-18 23:22:00
【问题描述】:

我正在使用 Android Studio 构建我的第一个应用,我想在其中使用 Material Design 组件,例如卡片。

我想我知道如何通过编写代码来添加这些,但我想知道,是否有可能以某种方式在设计选项卡的调色板中添加 cardview、recycleview 等?

【问题讨论】:

  • 如果你学习,你应该优先考虑通过代码而不是拖放来完成它
  • 您应该安装 Android 设计支持库以获得额外的材料设计组件,例如 Cardview。使用 gradle : 'com.android.support:design:23.3.0'

标签: android android-studio material-design


【解决方案1】:

每当我使用 Android Studio 创建 Material Design 应用程序时,我总是通过 xml 创建卡片。然后在设计视图中正确显示。但是,设计视图左侧的小部件只是简单的图像,它们是实际 Android API 的一部分(不需要像您的情况那样的任何额外引用)。要将卡片添加到您的页面,请使用以下 xml:

<android.support.v7.widget.CardView
        android:id="@+id/cardview"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:elevation="100dp"
        card_view:cardBackgroundColor="@color/cardview_initial_background"
        card_view:cardCornerRadius="8dp"
        android:layout_marginLeft="@dimen/margin_large"
        android:layout_marginRight="@dimen/margin_large"
        >

    //add any widgets which you want inserted in the card here
</android.support.v7.widget.CardView>

代码取自here

希望这会有所帮助:)

【讨论】:

  • 链接已失效。
猜你喜欢
  • 2016-10-11
  • 1970-01-01
  • 1970-01-01
  • 2015-10-28
  • 2015-03-08
  • 1970-01-01
  • 1970-01-01
  • 2020-08-21
  • 2020-06-15
相关资源
最近更新 更多