How to develop for tablet using Worklight?

与世无争的帅哥 提交于 2019-12-08 06:19:22

问题


I have develop my UI under common folder, then I create a skin for my tablet and name it as android.tablet. But when I run it on my tablet simulator, it looks like this:

I use below code in skinLoader.js:

var userAgent = navigator.userAgent;
var skinName = "default";
//android tablet
if(userAgent.toLowerCase().indexOf("android") != -1 &&
    userAgent.toLowerCase().indexOf("mobile") == -1){
    skinName = "android.tablet";
    alert("tablet!");
}
//android phone
else if(userAgent.toLowerCase().indexOf("android") != -1 &&
    userAgent.toLowerCase().indexOf("mobile") != -1){
    skinName = "default";
    alert("default!");
}

HTML:

<div data-role="page" id="homePage" class="fullWidth">
    <div data-role="header" data-tap-toggle="false">
        <div class="ui-title">...</div>
    </div>
    <div data-role="content" style="text-align: center">
        <a href="#" data-role="button" id="login" class="fullWidth">Login</a>
    </div>
</div>

CSS:

.fullWidth{
    width: 100% !important;
}

Why it can't be full screen? Any code I lack?


回答1:


Have you made sure to read the Worklight Skins training module?

The basic premise for Worklight Skins is this:

  1. Create a new Worklight project, application
  2. Add a skins-supported environment (Android, BlackBerry 6/7/10, iPhone, iPad)
  3. For the sake of simplicity, update skinLoader.js to point to the skin's folder ("android.skin" for example)
  4. Create a CSS and JS files in the respective folders of the skin
  5. Copy the HTML file from common to the skin folder
  6. Do whatever you want in the CSS, JS and HTML in the skin folder, like changing color and adding an alart
  7. Build all & Deploy
  8. Verify the color and alert are displayed, ensuring it is the skin and not default that was loaded.

To preview the skin's web resources:

  1. Right-click on the android environment folder
  2. Choose Run As >> Preview...
  3. Select the skin from the Skin dropdown
  4. Click the Run button

You should now see the skin (previewing only displays web resources, not native parts if you have any).

If this fails, you can try altering the URL as follows.
This essentially strips away the MBS container and displays only the web resources.

From:

http://localhost:8080/_MobileBrowserSimulator/index.html?webpage=http://localhost:8080/apps/services/preview/your-app-name/android/1.0/your-skin-name-here/your-html-filename-here.html&devicesFilePath=devices.json&platform=android&ips=169.254.236.125,9.148.205.249,10.0.0.2

To:

http://localhost:8080/apps/services/preview/your-app-name/android/1.0/your-skin-folder-name/your-html-filename-here.html

This process will hopefully get more streamlined in a future release...


As for it being full screen or not, that's completely in the hands of the developer (your CSS, etc), and not Worklight's.

I see you're using jQuery Mobile, look at these:

  • http://jquerymobile.com/demos/1.2.1/docs/toolbars/bars-fullscreen.html
  • How to set header to full screen mode in jQuery Mobile?



回答2:


  1. If you want to develop for Android tablet make sure that element in AndroidManifest.xml (inside of Android project) declared that. By default only normalScreens support is set to true.
  2. You might need to adjust CSS. By default it has fixed width of 320px and dynamic height, which pretty much is what you have on a screenshot.


来源:https://stackoverflow.com/questions/16850074/how-to-develop-for-tablet-using-worklight

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!