android.webkit.WebView.getLayoutParams()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(3.5k)|赞(0)|评价(0)|浏览(165)

本文整理了Java中android.webkit.WebView.getLayoutParams()方法的一些代码示例,展示了WebView.getLayoutParams()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebView.getLayoutParams()方法的具体详情如下:
包路径:android.webkit.WebView
类名称:WebView
方法名:getLayoutParams

WebView.getLayoutParams介绍

暂无

代码示例

代码示例来源:origin: robolectric/robolectric

@Test
public void shouldReturnPreviouslySetLayoutParams() {
 assertThat(webView.getLayoutParams()).isNull();
 LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
 webView.setLayoutParams(params);
 assertThat(webView.getLayoutParams()).isSameAs(params);
}

代码示例来源:origin: stackoverflow.com

WebView webview = (WebView)findViewById(R.id.webview);
MarginLayoutParams marginsParams = new MarginLayoutParams(webview.getLayoutParams());
marginsParams.setMargins(50, 50,1024-50, 600-50);
RelativeLayout.LayoutParams lp = new LayoutParams(marginsParams);
webview.setLayoutParams(lp);

代码示例来源:origin: stackoverflow.com

WebView w =new WebView(this);
     LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
     w.setLayoutParams(lp);
     w.getLayoutParams().width = 200;
     w.getLayoutParams().height = 200;
     ( (ViewGroup) insertPoint ).addView(w) ;

代码示例来源:origin: stackoverflow.com

Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();     
int screenWidth = display.getWidth();
int screenHeight = display.getHeight();

WebView mWebView = (WebView) findViewById(R.id.myWebView);
ViewGroup.LayoutParams params = mWebView.getLayoutParams();

params.width = screenWidth*3/4;//or whatever you need, relative to the screen size
params.height = screenHeight*3/4;

//you can also add margins programmatically here, which may be better than using setX/setY

mWebView.setLayoutParams(params);

代码示例来源:origin: stackoverflow.com

final WebView wv = new WebView(main);
new AsyncTask<Void,Void,Void>(){
  @Override
  protected Void doInBackground(Void... params) {
    try {
      Thread.sleep(2000);
    } catch (InterruptedException ex){
      ex.printStackTrace();
    }
    return null;
  }

  @Override
  protected void onPostExecute(Void result) {
    mainLayout.addView(wv);
    LayoutParams params = wv.getLayoutParams();
    // Edit those params as you need, then call
    wv.setLayoutParams(params);
  }   

}.execute();

代码示例来源:origin: grzegorznittner/chanu

static public void setImageDimensions(ThreadViewHolder viewHolder, Point targetSize) {
  //ViewGroup.LayoutParams params = viewHolder.list_item_image_expanded.getLayoutParams();
  if (DEBUG) Log.i(TAG, "setImageDimensions() to " + targetSize.x + "x" + targetSize.y);
  if (viewHolder.list_item_image_expanded_click_effect != null) {
    ViewGroup.LayoutParams params2 = viewHolder.list_item_image_expanded_click_effect.getLayoutParams();
    if (params2 != null) {
      params2.width = targetSize.x;
      params2.height = targetSize.y;
    }
  }
  if (viewHolder.list_item_image_expanded_webview != null) {
    ViewGroup.LayoutParams params3 = viewHolder.list_item_image_expanded_webview.getLayoutParams();
    if (params3 != null) {
      params3.width = targetSize.x;
      params3.height = targetSize.y;
    }
  }
  if (viewHolder.list_item_image_expanded_wrapper != null) {
    ViewGroup.LayoutParams params4 = viewHolder.list_item_image_expanded_wrapper.getLayoutParams();
    if (params4 != null) {
      //params3.width = params.width; always match width
      params4.height = targetSize.y;
    }
  }
}

代码示例来源:origin: andforce/iBeebo

int height = width * options.outHeight / options.outWidth;
ViewGroup.LayoutParams layoutParams = webView.getLayoutParams();
layoutParams.width = width;
layoutParams.height = height;

代码示例来源:origin: appnexus/mobile-sdk-android

ViewGroup.LayoutParams spaceParams = webViewSpace.getLayoutParams();
ViewGroup webViewSpaceParent = ((ViewGroup) webViewSpace.getParent());
int index = webViewSpaceParent.indexOfChild(webViewSpace);

相关文章

微信公众号

最新文章

更多

WebView类方法