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

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

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

WebView.getWidth介绍

暂无

代码示例

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

public void onGlobalLayout()
  ViewSize = wv.getWidth();
  wv.getViewTreeObserver().removeGlobalOnLayoutListener(this);

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

public void run() {
  try {
    final Bitmap bmp = Bitmap.createBitmap(webView.getWidth(),
      webView.getHeight(), Bitmap.Config.ARGB_8888);
    final Canvas c = new Canvas(bmp);

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

if(wv.getWidth() > 0){
  setup();
}else{

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

mWebView.setWebViewClient(new WebViewClient() {
  public void onPageFinished(WebView view, String url) {

    // Column Count is just the number of 'screens' of text. Add one for partial 'screens'
    int columnCount = Math.floor(view.getHeight() / view.getWidth())+1;

    // Must be expressed as a percentage. If not set then the WebView will not stretch to give the desired effect.
    int columnWidth = columnCount * 100;

    String js = "var d = document.getElementsByTagName('body')[0];" + 
      "d.style.WebkitColumnCount=" + columnCount + ";" + 
      "d.style.WebkitColumnWidth='" + columnWidth + "%';";
    mWebView.loadUrl("javascript:(function(){" + js + "})()");
  }
});

mWebView.loadUrl("file:///android_asset/chapter.xml");

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

public void _dropText(WebView wv, String text, float x, float y) {
  wv.loadUrl("javascript:dropText('" + text + "', " + x + ", " + y + ", " + wv.getHeight()
      + ", " + wv.getWidth() + ")");
}

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

private WebView mWebView;
public void onSavePhoto(int top, int left, int width, int height){
  Bitmap bitmap = Bitmap.createBitmap(mWebView.getWidth(), mWebView.getHeight(), Bitmap.Config.ARGB_8888);
  Canvas canvas = new Canvas(bitmap);
  mWebView.draw(canvas);

  // crop bitmap:
  Bitmap croppedBitmap = Bitmap.createBitmap(bitmap, left, top, width, height);
}

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

@Override
public void onWindowFocusChanged(boolean hasFocus) {

  // need to set correct proportions of webview to match image
  super.onWindowFocusChanged(hasFocus);
  WebView mWrapper = (WebView) findViewById(R.id.webview);
  int w = mWrapper.getWidth();
  int h = mWrapper.getHeight();
  while ( w * 1.28 > h ) {
    w--;
  }
  LayoutParams params = new LinearLayout.LayoutParams( (int) w, LinearLayout.LayoutParams.FILL_PARENT );
  mWrapper.setLayoutParams(params);
}

代码示例来源:origin: hsk256/WebviewCapture

/**
 * 获得快照
 */
private void getSnapshot() {
    float scale = webView.getScale();
    int webViewHeight = (int) (webView.getContentHeight()*scale+0.5);
    Bitmap bitmap = Bitmap.createBitmap(webView.getWidth(),webViewHeight, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    webView.draw(canvas);
    try {
      String fileName = Environment.getExternalStorageDirectory().getPath()+"/webview_capture2.jpg";
      FileOutputStream fos = new FileOutputStream(fileName);
      //压缩bitmap到输出流中
      bitmap.compress(Bitmap.CompressFormat.JPEG, 70, fos);
      fos.close();
      Toast.makeText(WebviewFromDraw.this, "截屏成功", Toast.LENGTH_LONG).show();
      bitmap.recycle();
    } catch (Exception e) {
      Log.e(TAG, e.getMessage());
    }
}

代码示例来源:origin: hylinux1024/Componentization

/**
 * Convert view to an image.  Can be used to make animations smoother.
 *
 * @param context           The current Context or Activity that this method is called from
 * @param viewToBeConverted View to convert to a Bitmap
 * @return Bitmap object that can be put in an ImageView.  Will look like the converted viewToBeConverted.
 */
public static Bitmap viewToImage(Context context, WebView viewToBeConverted) {
  int extraSpace = 2000; //because getContentHeight doesn't always return the full screen height.
  int height = viewToBeConverted.getContentHeight() + extraSpace;
  Bitmap viewBitmap = Bitmap.createBitmap(viewToBeConverted.getWidth(), height, Bitmap.Config.ARGB_8888);
  Canvas canvas = new Canvas(viewBitmap);
  viewToBeConverted.draw(canvas);
  //If the view is scrolled, cut off the top part that is off the screen.
  try {
    int scrollY = viewToBeConverted.getScrollY();
    if (scrollY > 0) {
      viewBitmap = Bitmap.createBitmap(viewBitmap, 0, scrollY, viewToBeConverted.getWidth(), height - scrollY);
    }
  } catch (Exception ex) {
    Log.e("PercolateAndroidUtils", "Could not remove top part of the webview image.  ex=" + ex);
  }
  return viewBitmap;
}

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

class WebViewUtil {

  public static void scaleTo(WebView view, Int size) {
    double currentHeight = view.getHeight();
    double currentWidth = view.getWidth();

    double scaleX = size / currentWidth;
    double scaleY = size / currentHeight;
    double scale = Math.min(scaleX, scaleY);

    view.scaleX(scale); view.scaleY(scale);
  }

}

代码示例来源:origin: zhangke3016/GeneratePicture

/**
 * 截屏
 *
 * @return
 */
public Bitmap getScreen() {
  Bitmap bmp = Bitmap.createBitmap(webView.getWidth(), 1, Bitmap.Config.ARGB_8888);
  int rowBytes = bmp.getRowBytes();
  bmp = null;
  if (rowBytes*webView.getHeight()>=getAvailMemory()){
    return null;
  }
  bmp = Bitmap.createBitmap(webView.getWidth(), webView.getHeight(), Bitmap.Config.ARGB_8888);
  Canvas canvas = new Canvas(bmp);
  webView.draw(canvas);
  return bmp;
}
@Override

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

/**
 * WevView screenshot
 * 
 * @param webView
 * @return
 */
public static Bitmap screenshot(WebView webView, float scale11) {
  try {
    float scale = webView.getScale();
    int height = (int) (webView.getContentHeight() * scale + 0.5);
    Bitmap bitmap = Bitmap.createBitmap(webView.getWidth(), height, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    webView.draw(canvas);
    return bitmap;
  } catch (Exception e) {
    e.printStackTrace();
  }
  return null;
}

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

public void onGlobalLayout()
  ViewSize = wv.getWidth();
  wv.getViewTreeObserver().removeGlobalOnLayoutListener(this);

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

public void onGlobalLayout()
  ViewSize = wv.getWidth();
  wv.getViewTreeObserver().removeGlobalOnLayoutListener(this);

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

int    width   = displayMetrics.widthPixels;
float  density = displayMetrics.density;
int    wvWidth = wv.getWidth();
int    wvHeight= wv.getHeight();
float  wvScaleX= wv.getScaleX();

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

text + ", "
(webview.getHeight()) + ", "
+ (webview.getWidth()) + ")");

代码示例来源:origin: com.googlecode.android-query/android-query

if(wv.getWidth() > 0){
  setup();
}else{

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

long delta = 100;
long downTime = SystemClock.uptimeMillis();
float x = webview.getLeft() + webview.getWidth()/2; //in the middle of the webview
float y = webview.getTop() + webview.getHeight()/2;

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

pLimit=webView.localToScene(webView.getWidth(),webView.getHeight());
webView.lookupAll(".scroll-bar").stream()
    .map(s->(ScrollBar)s).forEach(s->{

相关文章

微信公众号

最新文章

更多

WebView类方法