Sunday, 3 April 2022

TextButton default color in dark theme

Trying to change the default color for all TextButtons in my Android app w/ material. I see that I can style a "materialButtonStyle" and "materialButtonOutlinedStyle". However I do not see an attribute for a text button, possible something like "materialButtonTextStyle"

<style name="AppTheme" parent="Theme.MaterialComponents">
  <item name="materialButtonStyle">@style/myButton</item>
  <item name="materialButtonOutlinedStyle">@style/myButtonOutlined</item>
</style>

Example button:

<Button
    android:id="@+id/my_button"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    style="@style/Widget.MaterialComponents.Button.TextButton"
    android:text="Text Button" />

Is it possible to change the style globally for all material text buttons?

EDIT: Tried this from the theming-buttons material docs.

<style name="AppTheme" parent="Theme.MaterialComponents">
  <item name="borderlessButtonStyle">@style/Widget.App.Button.TextButton</item>
</style>

<style name="Widget.App.Button.TextButton" parent="Widget.MaterialComponents.Button.TextButton">
    <item name="materialThemeOverlay">@style/ThemeOverlay.App.Button.TextButton</item>
</style>

<style name="ThemeOverlay.App.Button.TextButton" parent="">
    <item name="colorPrimary">@color/md_purple_600</item>
</style>

However still not styling the text color for all text buttons.



from TextButton default color in dark theme

No comments:

Post a Comment