com.google.android.material.button.MaterialButton Android 中的“OutlinedButton”样式

问题描述

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

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

enter image description here

// 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" />

解决方法

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

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...