首页 > 解决方案 > 材料设计在android studio中不起作用

问题描述

implementation 'com.google.android.material:material:1.0.0' 在 Build.gradle添加了以下依赖项

<com.google.android.material.button.MaterialButton
        style="@style/Widget.MaterialComponents.Button.OutlinedButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="36dp"
        android:layout_marginTop="88dp"
        android:background="@drawable/ic_launcher_background"
        android:text="Click Me"
        android:textColor="@color/colorAccent"
        android:textSize="15sp"
        app:backgroundTint="#00FFFFFF"
        app:iconTint="@color/colorAccent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:strokeColor="@color/colorAccent"
         />

常规按钮已形成,但应该有一个大纲按钮,因为我使用了这种样式: style=@style/Widget.MaterialComponents.Button.OutlinedButton

选择的最低 Api 是否有任何问题或任何其他问题,请帮助我解决这个问题,谢谢

标签: javaandroidandroid-studiomaterial-design

解决方案


在基本应用程序主题中使用 Material 组件主题作为父级。像下面

<!-- Base application theme. -->
<style name="AppTheme" parent="**Theme.MaterialComponents.Light.NoActionBar**">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

推荐阅读