图片自适应WebView大小
来源:互联网 发布:app图片编辑软件 编辑:程序博客网 时间:2024/05/03 13:16
mainActivity如下:
package com.cn.testwebview;import android.os.Bundle;import android.view.MotionEvent;import android.view.View;import android.webkit.WebView;import android.app.Activity;/** * Demo描述: * WebView显示图片,但有的图片很小不能铺满整个WebView. * 现解决 */public class MainActivity extends Activity { private WebView mWebView;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.main);init();} private void init(){ mWebView=(WebView) findViewById(R.id.webview); mWebView.setVerticalScrollBarEnabled(false); mWebView.setHorizontalScrollBarEnabled(false); mWebView.getSettings().setJavaScriptEnabled(true);mWebView.getSettings().setUseWideViewPort(true);mWebView.getSettings().setLoadWithOverviewMode(true);String imageUrl="http://csdnimg.cn/www/images/pic_foot_gongshang.png"; String data = "<p><img src=\""+imageUrl+"\" width=\"100%\""+" height=\"100%\""+" /></p>"; mWebView.loadDataWithBaseURL("", data, "text/html", "UTF-8", ""); //禁止WebView滑动 mWebView.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { return (event.getAction() == MotionEvent.ACTION_MOVE); } }); }}
main.xml如下:
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#eee" > <ImageView android:id="@+id/imageView" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/ic_launcher" /> <RelativeLayout android:layout_width="fill_parent" android:layout_height="match_parent" android:layout_below="@id/imageView" android:layout_marginLeft="20dip" android:layout_marginRight="20dip" ><WebView android:id="@+id/webview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_marginBottom="20dp" /> </RelativeLayout></RelativeLayout>
- 图片自适应WebView大小
- Android 如何让图片自适应WebView大小
- WebView自适应屏幕大小
- Webview 自适应屏幕大小
- WebView自适应屏幕大小
- webView自适应屏幕大小
- webview加载html图片过大左右滑动的解决/webview加载图片自适应大小
- webview加载html图片过大左右滑动的解决/webview加载图片自适应大小
- ios自适应webview图片
- webview 图片自适应解决方案
- WebView图片自适应屏幕
- WebView图片自适应屏幕
- WebView图片自适应屏幕
- webview图片自适应解决方案
- webView图片自适应屏幕
- WebView图片自适应屏幕
- webview 对图片自适应
- webview网页自适应手机屏幕大小
- Java 根据定路径删除文件和文件夹下的所有文件
- 主方法研究
- 不健康的生活终于让身体有了反应
- 使用PhoneGap命令行工具创建IOS PhoneGap项目及无证书真机调试
- hadoop0.2X版本和1.0X版本的调度器配置区别
- 图片自适应WebView大小
- STL的内存分配(各种allocator)
- MyBatis学习(三)- 小结
- 多线程
- DDR1
- RMAN-06023: no backup or copy of datafile 6 found to restore
- 平.凡
- Linux 信号signal处理机制
- httpClient4.x 爬虫教学