小编han*_*789的帖子

“更改材质轮廓颜色”按钮不起作用

我想更改活动切换按钮的颜色。但仅仅改变rippleColor 就会产生影响。我希望自定义活动按钮的背景颜色和文本颜色。

<style name="ToggleButtonGroupStyle" parent="Widget.MaterialComponents.Button.OutlinedButton">
            <item name="rippleColor">@color/colorAccent</item>
</style>

Run Code Online (Sandbox Code Playgroud)

在下面的toggleButtonGroup中,我使用了上面的这种样式:

         <com.google.android.material.button.MaterialButtonToggleGroup
            android:id="@+id/priority_btn_group"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:layout_alignParentLeft="true"
            app:selectionRequired="true"
            app:singleSelection="true"
            app:checkedButton="@+id/btn_one"
            >

            <com.google.android.material.button.MaterialButton
                android:id="@+id/btn_one"
                style="@style/ToggleButtonGroupStyle"
                android:layout_width="@dimen/priority_btn_width"
                android:layout_height="wrap_content"
                android:shadowColor="@color/project_text"
                android:text="0" />

            <com.google.android.material.button.MaterialButton
                style="@style/ToggleButtonGroupStyle"
                android:layout_width="@dimen/priority_btn_width"
                android:layout_height="wrap_content"
                android:text="!" />

            <com.google.android.material.button.MaterialButton
                style="@style/ToggleButtonGroupStyle"
                android:layout_width="@dimen/priority_btn_width"
                android:layout_height="wrap_content"
                android:text="!!" />

            <com.google.android.material.button.MaterialButton
                style="@style/ToggleButtonGroupStyle"
                android:layout_width="50dp"
                android:layout_height="wrap_content"
                android:text="!!!" />


        </com.google.android.material.button.MaterialButtonToggleGroup>

Run Code Online (Sandbox Code Playgroud)

有人能给我提示一下这里的问题是什么吗?谢谢 :)

android android-theme android-button android-styles material-components-android

8
推荐指数
1
解决办法
2752
查看次数