商品展示,关于商品详情,服务端是用的html,的图片尺寸过大,怎么处理? 后台是用的FCKeditor上传的商品详情,保存为html 格式 。因为在网站上也要显示,图片的尺寸较大,在手机上图片显示不下,怎么破?有没有好的意见?首次在CSDN提问,不懂行事。。请多包涵手机fckeditor 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你如果向在android客户端展现图片,却因为图片的尺寸过大,你可以截取图片的尺寸 protected Bitmap scaleImg(Bitmap bm, int newWidth, int newHeight) { // 图片源 // Bitmap bm = BitmapFactory.decodeStream(getResources() // .openRawResource(id)); // 获得图片的宽高 int width = bm.getWidth(); int height = bm.getHeight(); // 设置想要的大小 int newWidth1 = newWidth; int newHeight1 = newHeight; // 计算缩放比例 float scaleWidth = ((float) newWidth1) / width; float scaleHeight = ((float) newHeight1) / height; // 取得想要缩放的matrix参数 Matrix matrix = new Matrix(); matrix.postScale(scaleWidth, scaleHeight); // 得到新的图片 Bitmap newbm = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, true); return newbm; } 因为服务端丢给我的是个html 客户端会直接在broswer中显示。。所以截取图片太麻烦了 如果是htm的话,想要控制图片的尺寸在客户端应该无法实现的,就不清楚了,只能是伸缩htm了 一样可以实现。new Thread() { public void run() { Spanned spanned = Html.fromHtml(NEWS_CONTENT, new ImageGetter() { @Override public Drawable getDrawable(String source) { // TODO Auto-generated method stub //这个地方对图片做处理 return drawable; } }, null); } }.start(); android下载控制 android;如何实现按钮的按下与抬起是赋不同值? 自己做的视频播放器 会卡的问题 更新ADT出现了错误,不懂?求帮忙。。 getResources()的作用 谁能解释一下其中的机制!!getSystemService()?? 想做一个Android项目,求提供源代码 android怎么让AlertDialog浮在锁屏的上方 求助! 用vlc播放rtsp视频,有时候黑屏,有时候连接正常,可能是什么原因? android报错LogCat报错如下 线程不能捕获connectionexcption异常问题
protected Bitmap scaleImg(Bitmap bm, int newWidth, int newHeight) {
// 图片源
// Bitmap bm = BitmapFactory.decodeStream(getResources()
// .openRawResource(id));
// 获得图片的宽高
int width = bm.getWidth();
int height = bm.getHeight();
// 设置想要的大小
int newWidth1 = newWidth;
int newHeight1 = newHeight;
// 计算缩放比例
float scaleWidth = ((float) newWidth1) / width;
float scaleHeight = ((float) newHeight1) / height;
// 取得想要缩放的matrix参数
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);
// 得到新的图片
Bitmap newbm = Bitmap.createBitmap(bm, 0, 0, width, height, matrix,
true);
return newbm;
}
因为服务端丢给我的是个html 客户端会直接在broswer中显示。。所以截取图片太麻烦了
一样可以实现。
new Thread() {
public void run() {
Spanned spanned = Html.fromHtml(NEWS_CONTENT,
new ImageGetter() { @Override
public Drawable getDrawable(String source) {
// TODO Auto-generated method stub
//这个地方对图片做处理
return drawable;
}
}, null);
}
}.start();