首页 > 解决方案 > Android中的com.google.android.material.button.MaterialButton“OutlinedButton”样式

问题描述

我使用了MaterialButton,但我的预期设计没有出现。在我的 xml 代码和样式下面。

我需要背景的白色而不是橙色,我可以做些什么来实现这一点。请提供您的建议。

在此处输入图像描述

// Material Design version I've used
implementation 'com.google.android.material:material:1.2.1'

**Color primary** means orange color.

<com.google.android.material.button.MaterialButton
                android:id="@+id/btnWatchVideo"
                style="@style/Widget.MaterialComponents.Button.OutlinedButton"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:text="@string/watch_video"
                android:textColor="@color/colorBlack"
                android:visibility="visible"
                app:strokeColor="@color/colorBlack"
                app:strokeWidth="2dp" />


<style name="SliderThemeBlack" parent="Theme.MaterialComponents.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorBlack</item>
        <item name="colorAccent">@color/colorPrimary</item>
        <item name="android:screenOrientation">portrait</item>
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowDrawsSystemBarBackgrounds">true</item>

Manifest:
    <activity android:name="xxx" 
    android:theme="@style/SliderThemeBlack"  android:windowSoftInputMode="stateHidden" />

标签: androidmaterial-designandroid-buttonmaterial-components-androidmaterial-components

解决方案


用于app:backgroundTint="@color/white"您的 MaterialButton


推荐阅读