0

I am attempting to display some formatted HTML inside of a webview. This HTML will have some basic formatting, such as images and paragraph tags etc.

The issue is that the HTML will take up the entire height of the screen. if I have some short content it take up the entire height of the screen.

What i want that height should adjust according to the content.

Does anyone know how I can get the height of the webview to work the way I want it to? Does this make sense?

os 7

This is my code.

HorizontalFieldManager contentview = new HorizontalFieldManager(Field.USE_ALL_WIDTH); 
listVfm.add(contentview);

BrowserFieldConfig config = new BrowserFieldConfig();
config.setProperty(BrowserFieldConfig.VIEWPORT_WIDTH, new Integer(
        Display.getWidth()));
config.setProperty(BrowserFieldConfig.INITIAL_SCALE, new Float(1.0));

config.setProperty(BrowserFieldConfig.USER_SCALABLE, Boolean.FALSE);
ProtocolController eventsProtocolController = new ProtocolController(bf2)
{
  public void handleNavigationRequest(BrowserFieldRequest request) throws Exception
  {
      bf2.setFocus();
    super.handleNavigationRequest(request);
  }
  };

 config.setProperty(BrowserFieldConfig.CONTROLLER, eventsProtocolController);
 bf2 = new BrowserField(config);
 bf2.displayContent("<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0 Transitional//EN'><HTML><HEAD><META NAME='Generator' CONTENT='EditPlus'><META NAME='Author' CONTENT=''><META NAME='Keywords' CONTENT=''><META NAME='Description' CONTENT=''> <meta name='viewport' CONTENT='width=device-width,height=device-height,minimum-scale=1,content= maximum-scale=1, maximum-scale=1'/></HEAD><BODY><p>some text.</p></BODY></HTML>", "http://localhost");
 contentview.add(bf2);
askquestion
  • 171
  • 1
  • 14
  • I am not aware of a way of dong this. Have you considered restricting the size yourself? I guess the problem is that if the content is smaller you want it smaller, but if it is bigger you want it full screen. There I think you are out of luck. But hopefully someone else has done it. – Peter Strange May 07 '14 at 13:18
  • @PeterStrange if i set this width=device-width,height=device-height then i will get height problem and if i will remove then webview is like jumping. first it will take full height and then content will set properly. – askquestion May 07 '14 at 13:26

0 Answers0