Languages

Menu
Sites
Language
Is there a way to get the screen width and height

I want add an image to UI, but I want to set it's width/height according to the screen size(the actually width/height of the emulaor or real device). Is there any sample code? Many thanks!

Responses

5 Replies
Alex Ashirov

Hi,

Please refer to the following links:

https://developer.tizen.org/dev-guide/2.3.0/org.tizen.mobile.native.appprogramming/html/guide/system/sysinfo.htm#screen

https://developer.tizen.org/dev-guide/2.3.0/org.tizen.mobile.native.appprogramming/html/tutorials/system_tutorial/system_info_tutorial.htm

colin Rao

Hi Alex,

Thanks for your help. I can get the screen size successful.

Post the sample code here for other guys reference. -_-

    
static void
get_system_info_int(char* key, int *value)
{
    int ret;
    ret = system_info_get_platform_int(key, &value);
	if (ret != SYSTEM_INFO_ERROR_NONE)
	{
	    // Error handling
	}
	dlog_print(DLOG_INFO, LOG_TAG, "screen size %s : %d", key, value);
	return;
}


    int screen_size_w, screen_size_h;

    get_system_info_int("tizen.org/feature/screen.width",&screen_size_w);
    get_system_info_int("tizen.org/feature/screen.height",&screen_size_h);

console log should be looks like:

01-20 17:21:08.397 : INFO / xxx ( 5044 : 5044 ) : screen size tizen.org/feature/screen.width : 480
01-20 17:21:08.407 : INFO / xxx ( 5044 : 5044 ) : screen size tizen.org/feature/screen.height : 800

 

colin Rao

The get_system_info_int(char *key, int *value) should be changed as bleow, otherwithe, the function call won't get the right value, as the local varable screen_size_w and screen_size_h in previous comment.

static void
get_system_info_int(char* key, int *value)
{
    int ret, val;
    ret = system_info_get_platform_int(key, &val);
    *value = val;
    if (ret != SYSTEM_INFO_ERROR_NONE)
	{
	    // Error handling
	}
	dlog_print(DLOG_INFO, LOG_TAG, "screen size %s : %d", key, val);
	return;
}

 

王 伟

https://developer.tizen.org/dev-guide/2.3.0/org.tizen.guides/html/native/system/sysinfo_n.htm#screen'

I draw line (0,100)  to (480, 100), not fill the screen, why?

cairo_move_to(cr, 0, 100);

cairo_line_to(cr, 480, 100);

cairo_stroke(cr);

Vikram

Hi, the code seems ok. Did you set the front color or set the line width?