Disable button focus outline

Hey everyone!

I’m a bit new to LVGL, and I’m trying to disable the button focus outline. I’ve tried applying the following style to my button, but the focus outline is still there:

lv_style_init(&style_button);
lv_style_set_outline_width(&style_button, 0);

If anyone can help me get rid of it, it would be much appreciated!

You have to pass the state for focused.

I am not sure what your code example is doing because it wouldn’t do anything if style_button doesn’t get added to an object.

lv_obj_add_style(obj, &style_button, LV_STATE_FOCUSED);

I have applied it like this:

lv_obj_t *btn = lv_btn_create(lv_scr_act()); 
lv_obj_set_size(btn, 200, 50); 
lv_obj_align(btn, LV_ALIGN_CENTER, 0, 0); 
lv_obj_add_style(btn, &style_button, 0 | LV_STATE_FOCUSED);

But the outline remains.
image

Try use LV_STATE_FOCUS_KEY

what are you setting on the style? You have outline and you also have border. I think the focus uses border. Set the opacity to zero. you do not have to use a style to do this either.

lv_obj_set_style_border_opa(btn, 0, LV_STATE_FOCUSED);

or

lv_obj_set_style_outline_opa(btn, 0, LV_STATE_FOCUSED);