语言

Menu
Sites
Language
Web View auto Rotation.

Hi i have made a shared library to open webview. I used it it is working fine.I have set

elm_win_wm_rotation_preferred_rotation_set( ad->popup_win,90);

How can i make it change the rotation according to application rotation which is calling the shared library.

响应

3 回复
colin Rao

Hi,

Possible, you can check the device rotation in this main loop event, as below sample code,

static void
ui_app_orient_changed(app_event_info_h event_info, void *user_data)
{
    /*APP_EVENT_DEVICE_ORIENTATION_CHANGED*/
	app_device_orientation_e orie;
	int r = app_event_get_device_orientation(event_info, &orie);
	dlog_print(DLOG_INFO, LOG_TAG, "[ui_app_region_changed] %d\n", orie);
	return;
}

 

rohit sijwali

Actually i am opening webview in a shared library.

 

EXPORT_API int openUrl(char * url)

{

 

appdata_s *ad=new appdata_s;

dlog_print(DLOG_ERROR,LOG_TAG,"webview popup");

 

    ad->popup_win = elm_win_add(NULL, "Url Window", ELM_WIN_DIALOG_BASIC);

// very important! if you don't make it close on back, user can't close it until push check or another button.

 

elm_win_wm_rotation_preferred_rotation_set( ad->popup_win,90);

eext_object_event_callback_add( ad->popup_win , EEXT_CALLBACK_BACK, fb_win_back_cb,ad->popup_win);

 

    int w,h;

    elm_win_screen_size_get( ad->popup_win , NULL, NULL, &w, &h);

    evas_object_move( ad->popup_win , 0, 0);

    int pw = w - w*PADDINGH, ph = h - h*PADDINGV;

    evas_object_resize( ad->popup_win , pw, ph);

 

    Evas_Object *bg = elm_bg_add( ad->popup_win );

    elm_bg_color_set(bg, 255, 255, 255);

    evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL);

elm_win_resize_object_add( ad->popup_win, bg);

evas_object_show(bg);

 

    Evas_Object *vbox = elm_box_add( ad->popup_win );

    evas_object_size_hint_align_set(vbox, EVAS_HINT_FILL, EVAS_HINT_FILL);

evas_object_size_hint_min_set(vbox, pw, ph);

elm_win_resize_object_add( ad->popup_win , vbox);

evas_object_show(vbox);

 

    ad->webview = ewk_view_add(evas_object_evas_get( ad->popup_win ));

    evas_object_size_hint_align_set(ad->webview, EVAS_HINT_FILL, EVAS_HINT_FILL);

ewk_view_url_set(ad->webview, url);

 

elm_box_pack_end(vbox, ad->webview);

evas_object_show(ad->webview);

 

 

 

evas_object_size_hint_min_set(ad->webview, pw, ph);

evas_object_show(ad->popup_win );

dlog_print(DLOG_ERROR,LOG_TAG,"Returning mfbLogin");

return 0;

}

I am calling this function from another applicatin. So i cannot get event_info

 

Alex Dem

Hi,
Maybe you could try to request device orientation periodically (using timer for example) with app_event_get_device_orientation() . 
Alexey.