How to Display Webview in fixed width and height

后端 未结 2 1720
一生所求
一生所求 2021-01-25 17:47

Sorry, I\'ve been searching this forum and got no exact answer. so I ask my own.

I have a class that display two layouts , glView and webview , with target portrait scre

2条回答
  •  无人及你
    2021-01-25 18:16

    You can do this using RelativeLayout.LayoutParams class:

    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(640, 480);
    params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    webView.setLayoutParams(params);
    

    then add the webview to the layout. You can locate the other view at the bottom of the screen with a new LayoutParams instance and addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);

提交回复
热议问题