This is a migrated thread and some comments may be shown as answers.

Best practices to display images and resize according to device and orientation

6 Answers 249 Views
General Discussion
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
CodeMaster2008
Top achievements
Rank 1
CodeMaster2008 asked on 19 Jan 2013, 08:06 PM
Hi there;

I just started with Icenium and mobile development and 3 days after I download Icenium  Graphite I was able to put together a small application. Congrats for the excellent product!

As for the question, basically the title of this post says it all.

I'm building an application that will be used on tablets and phones.
I will be adding a image header,similar to this demo:

http://demos.kendoui.com/mobile/scroller/index.html

In the demo they are using an image which is 900 x 675 and adjusting it to fit the available width.

Is it the best practice for those situations or should I have different images and use some javascript code to get the right image for the right device/orientation?

Thanks in advance;

6 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 21 Jan 2013, 10:35 AM
Hi, Emerson

You could use media queries for that. With media queries you can set a different styles depending on device screen size and DPI.

Here is an example:
<!-- Phone 720x1280 High DPI (aka Google Nexus) -->
<link rel="stylesheet" media="only screen and (min-device-width: 720px) and (max-device-width: 1280px) and (-webkit-device-pixel-ratio:2)" href="styles/phone-1280.css" type="text/css" />
 
<!-- Tablet 500x1024 Low DPI (aka Kindle Fire) -->
<link rel="stylesheet" media="only screen and (min-device-width: 600px) and (max-device-width: 1024px) and (-webkit-device-pixel-ratio:1)" href="styles/tablet-600-1024.css" type="text/css" />
 
<!-- Tablet 768x1024 High DPI (aka iPad3") -->
<link rel="stylesheet" media="only screen and (min-device-width: 768px) and (max-device-width: 1024px) and (-webkit-device-pixel-ratio:2)" href="styles/tablet-1024-hdpi.css" type="text/css" />

You could checkout our demo where we use media queries set HD images for devices with retina displays and other high DPI displays.

More information on media queries: here 

I hope this information helps you.
Good luck and if you have any further questions please do not hesitate to contact us.

Greetings,
Ivan Ivanov
the Telerik team

Share feedback and vote for features on our Feedback Portal.
Want some Kendo UI online training - head over to Pluralsight.
0
CodeMaster2008
Top achievements
Rank 1
answered on 21 Jan 2013, 09:35 PM
That helps, thanks a lot.
0
Pierre Chew
Top achievements
Rank 1
answered on 15 May 2013, 06:56 PM
Hello,

I am trying to get these rules to work in the simulator.  They appear to be applied correctly on the phone but not the simulator.  Is that possible?  Specifically the "max-device-width" style sheet rules seem to be getting ignored (the orientation ones seem to work fine).

Thanks,

Pierre
0
Steve
Telerik team
answered on 16 May 2013, 11:22 AM
Hi Pierre,

Thanks for bringing this to our attention, indeed media queries have some quirks in the simulator and we would look into improving their support. For the time being as you have found out, you can test on real device or adopt other techniques for conditional content rendering e.g. adaptive css via javascript.

All the best,
Steve
the Telerik team

Don't miss the Icenium May Release Keynote - sign up now!
Share feedback and vote for features on our Feedback Portal.
0
Dev
Top achievements
Rank 1
answered on 08 Jul 2015, 05:15 PM
What's the status of this? It would seems there are still 'quirks' with media queries within the simulator.
0
Tina Stancheva
Telerik team
answered on 13 Jul 2015, 03:55 PM
Hello,

The Device Simulators in AppBuilder still don't support media queries. We have looked into different options to provide the CSS parser with simulated device sizes but we haven't yet found a reliable approach to accomplish this task. However, we have a story still logged in our internal issue tracking system and if we find a suitable implementation, we will definitely implement it.

In the meantime, you can test media queries directly on the devices, as previously mentioned, or in the device native emulators, which are now supported in all AppBuilder clients.

Regards,
Tina Stancheva
Telerik
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
Tags
General Discussion
Asked by
CodeMaster2008
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
CodeMaster2008
Top achievements
Rank 1
Pierre Chew
Top achievements
Rank 1
Steve
Telerik team
Dev
Top achievements
Rank 1
Tina Stancheva
Telerik team
Share this question
or