언어 설정

Menu
Sites
Language
Web view scale not changing

Hi All,

I have a webview of size 300x250 which loads url from web say http://www.google.com

I'm trying to scale the webview so that the page fits properly based on the frame of webview, however when applying the scale, it seems to be unchanged.

Could anyone point out what could be wrong in the following code?

/* WebView */

    Evas_Object *evas = evas_object_evas_get(ad->win);
    web_view = ewk_view_add(evas);
    evas_object_move(web_view, 50, 50);
    evas_object_resize(web_view, 300, 250);
    evas_object_show(web_view);

    ewk_view_url_set(web_view, "http://www.google.com");

    web_view_apply_scale(0.5);

static void web_view_apply_scale (float scale_factor)
{

    float currentScaleFactor = ewk_view_scale_get(web_view);

    if((currentScaleFactor == -1) || (scale_factor == currentScaleFactor)) {
        // do nothing, undefined scale factor or scale factor equals current scale factor
    } else {

        // apply scale
        Eina_Bool success = ewk_view_scale_set(web_view, scale_factor, 0, 0);
        if(success) {
            dlog_print(DLOG_INFO, LOG_TAG, "web view scale success, current scale: %f", ewk_view_scale_get(web_view));
        } else {
            dlog_print(DLOG_INFO, LOG_TAG, "web view scale failure, current scale: %f", ewk_view_scale_get(web_view));
        }
    }
}

 

Console always prints:

03-29 15:11:29.146 : INFO / websample ( 3670 : 3670 ) : web view scale success, current scale: 1.000000

I tried changing the scale by adding a callback to web view loading finished but there it prints scale as 0.36 when setting scale as 0.5. Visually there is no change noticeable.

Is the issue because im passing 0,0 for the position to apply scale at? I don't know how to scale the webview from the webview's center point without user interaction.

Any help would be great.

Edited by: Anup DSouza on 28 3월, 2017

Responses

3 댓글
Yasin Ali

Hi,

You may try with program design in code like:

static void my_table_pack(Evas_Object *table, Evas_Object *child, int x, int y,
     int w, int h) {
 evas_object_size_hint_align_set(child, EVAS_HINT_FILL, EVAS_HINT_FILL);
 evas_object_size_hint_weight_set(child, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
 elm_table_pack(table, child, x, y, w, h);
 evas_object_show(child);
}

static void create_base_gui(appdata_s *ad) {

....................
 /* WebView 1*/
   /* ... ... ... */
 my_table_pack(table, web_view, 0, 2, 3, 8);
....................

}


Hope it will work.
If you find my post is helpful for you, please mark it as the Best Answer to promote this post to others.

Anup DSouza

Hi Yasin,

Thank you for your reply. Actually my query is regarding the webview content scale. I'm able to size the webview properly however when setting a small size, the web page content displaying inside the webview overflows and the webview shows scroll bars. I want to scale the webview content to avoid the scroll bars.

Any idea how to achieve this?

Yasin Ali