语言

Menu
Sites
Language
Button Position (ELM Gear S2)

The following code generates the basic UI, including a button. The button should appear at the bottom of the screen, but it is at top for some reason.

Any help is appreciated!

static void create_base_gui(appdata_s *ad, int width, int height)
{
    int ret;
    watch_time_h watch_time = NULL;

    /* Window */
    ret = watch_app_get_elm_win(&ad->win);
    if (ret != APP_ERROR_NONE) {
        dlog_print(DLOG_ERROR, LOG_TAG, "failed to get window. err = %d", ret);
        return;
    }

    evas_object_resize(ad->win, width, height);

    /* Conformant */
    ad->conform = elm_conformant_add(ad->win);
    evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    elm_win_resize_object_add(ad->win, ad->conform);
    evas_object_show(ad->conform);

    /* Label*/
    ad->label = elm_label_add(ad->conform);
    evas_object_resize(ad->label, width, height / 3);
    evas_object_move(ad->label, 0, height / 3);
    evas_object_show(ad->label);

    /*OK Button*/
    ad->button = elm_button_add(ad->conform);
    evas_object_resize(ad->button, width, height / 4);
    elm_object_style_set(ad->button, "bottom/queue");
    elm_object_text_set(ad->button, "CLICK");
    evas_object_smart_callback_add(ad->button, "clicked", btn_clicked_cb, ad);
    evas_object_show(ad->button);

    ret = watch_time_get_current_time(&watch_time);
    if (ret != APP_ERROR_NONE)
        dlog_print(DLOG_ERROR, LOG_TAG, "failed to get current time. err = %d", ret);

    update_watch(ad, watch_time, 0);
    watch_time_delete(watch_time);

    /* Show window after base gui is set up */
    evas_object_show(ad->win);
}

响应

4 回复
colin Rao

Hi, 

Because of my local environment issue, i cant testing your sample code on my gear s2. 

Suggest to check this section on IDE help doc Sample Descriptions > Native Application > Wearable Native

(Circle) Setting Time Sample 

Seems it's help for you.​

colin Rao

There is a sample wearable native project (Circle) Time Setting UI, you can create it from IDE and check its source code.

Jeongsu Kim
    ad->button = elm_button_add(ad->conform);
    evas_object_resize(ad->button, width, height / 4);
    elm_object_style_set(ad->button, "bottom/queue");
    elm_object_text_set(ad->button, "CLICK");
    evas_object_smart_callback_add(ad->button, "clicked", btn_clicked_cb, ad);
    evas_object_show(ad->button);

You just added a button but not set the position. You should call evas_object_move to place it as you want.

 

OR

 

You can use some layout like below. I modified it to make it works on my device.

static void
create_base_gui(appdata_s *ad)
{
    int ret;
    int width = 360;
    int height = 360;
//    watch_time_h watch_time = NULL;

    /* Window */
    ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE);
    elm_win_autodel_set(ad->win, EINA_TRUE);

    evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL);

    evas_object_resize(ad->win, width, height);

    /* Conformant */
    ad->conform = elm_conformant_add(ad->win);
    evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    elm_win_resize_object_add(ad->win, ad->conform);
    evas_object_show(ad->conform);

    /* Label*/
    ad->label = elm_label_add(ad->conform);
    evas_object_resize(ad->label, width, height / 3);
    evas_object_move(ad->label, 0, height / 3);
    evas_object_show(ad->label);

    Evas_Object* layout = elm_layout_add(ad->conform);
    elm_layout_theme_set(layout, "layout", "bottom_button", "default");

    /*OK Button*/
    ad->button = elm_button_add(ad->conform);
    evas_object_resize(ad->button, width, height / 4);
    elm_object_style_set(ad->button, "bottom");
    elm_object_text_set(ad->button, "CLICK");
//    evas_object_smart_callback_add(ad->button, "clicked", btn_clicked_cb, ad);
//    evas_object_show(ad->button);
    elm_object_part_content_set(layout, "elm.swallow.button", ad->button);

    elm_object_content_set(ad->conform, layout);

/*
    ret = watch_time_get_current_time(&watch_time);
    if (ret != APP_ERROR_NONE)
        dlog_print(DLOG_ERROR, LOG_TAG, "failed to get current time. err = %d", ret);

    update_watch(ad, watch_time, 0);
    watch_time_delete(watch_time);
*/

    /* Show window after base gui is set up */
    evas_object_show(ad->win);
}

I added a layout and set a theme as "layout", "bottom_button", "default".
It provides two swallow parts, one is "elm.swallow.content" for the content and "elm.swallow.button" for the button.

And I modified the style of button to "bottom" because I coundn't find any style "bottom/queue".

Leo Liao
group { 
  name: "elm/layout/bottom_button/default";
  parts {
    part { name: "elm.swallow.content";
      type: SWALLOW;
      scale: 1;
      description { state: "default" 0.0;
      }
    }
    part { name: "elm.swallow.button";
      type: SWALLOW;
      description { state: "default" 0.0;
        rel1.relative: 0.0 1.0;
        rel2.relative: 1.0 1.0;
        align: 0.5 1.0;
        fixed: 0 1;
        visible: 1;
      }
    }
  }
}

Here is the definition of "button_bottom":