How to remove default style on button

Hello guys,

What do you want to achieve?

I want to use the button widget with image background. I don’t want to use the button img widget because it’s missing the “LV_STATE_FOCUS” state.

The problem is that the button uses the default style on the app (blue background, shadows, and so on…) and it’s visible behind my image. Even when where it’s switch state, like “LV_STATE_FOCUS”.

What have you tried so far?

Solution n°1 : Manually remove all the effect on the button in SquareLine studio. Take a few time cause you have to do that in all states and effects.

Solution n°2 Adding this line to the code :

  // Need to add this line to remove default style (cause bad background color, shadow, etc...)
  lv_obj_remove_style(btn_setup, NULL, LV_STATE_FOCUS_KEY);
  lv_obj_remove_style(btn_setup, NULL, LV_STATE_EDITED);
  lv_obj_remove_style(btn_setup, NULL, LV_STATE_PRESSED);

Others

  • **SquareLine Studio version:1.4.1
  • **Operating system:Windows
  • **Target hardware:ESP32

Is there a way to import a “blank button” with no style ?

Thanks,
Thomas.

You don’t need to use the image button to have an image in the background of the button. You can set in the style menu the background color alfa to zero and the shadow’s width to zero. This way you will see only the image this way on the button.