android加载长图片的方法
1.很多应用都有加载一张长图片,用户可以上下拉动图片。
自己没有好的想法,那只好百度咯。结果都说用webview来实现,好吧那就只好先试一下了。
2.自己写了简单的html,然后webview加载。图片可以成功显示,但是因为图片太大了,webview需要左右上下拉动才能看到完整的图。
好吧,html应该也可以适配手机的宽度吧。奈何不会html啊,那只好再求助度娘了。找到一个css文件,可以用来做html的适配,好了,就用他了。
3,代码
css文件内容:
body,button,dd,dl,dt,fieldset,form,h1,h2,h3,h4,h5,h6,input,legend,li,ol,p,select,table,td,textarea,th,ul { margin: 0; padding: 0}body { min-width: 320px; font-family: 'microsoft yahei',Verdana,Arial,Helvetica,sans-serif; color: #333; -webkit-text-size-adjust: none}fieldset,img { border: 0}ol,ul { list-style: none}address,em { font-style: normal}a { color: #000; text-decoration: none}table { border-collapse: collapse}#clear { clear: both; width: 100%; background-color: #fff}#clear: after { display: block; clear: both; height: 1px; content: ''}img, fieldset { border: 0;}img { height: auto; width: auto\9; width:100%;}.content-step ul li .red{ color:#e5362b; background:none; width:inherit; vertical-align:inherit}* { -webkit-tap-highlight-color: rgba(0,0,0,0); -webkit-box-sizing: border-box; -moz-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box}.doc { padding:10px; margin: 0 auto;}.doc h1 {font-size:16px;color:#333;padding:10px 0;font-weight:500;} .shop-title {padding:10px 0;} .author {padding:10px 0;font-size:12px;} .author span {color:#333;} .author a {color:#2B8CB2;} .content {padding:20px 0;} .f-bold {background-color:#CCC5C0;color:#E5362B;padding:5px;line-height:24px;font-size:14px;} .content p {line-height:24px;padding:10px 0;text-indent:2em; font-size:14px;} .content-time {padding:20px 0;color:#000;font-weight:500;line-height:40px;} .content-time span {color:#000;} .content-time em {color:#E5362B;} .content-step {} .content-step ul {padding:20px 0;} .content-step ul li {line-height:30px;color:#5D5D5D; font-size:14px; padding-top:0} .content-step ul li .icon{ display:inline-block; background:url(../images/icon.jpg) no-repeat scroll; width:20px; height:20px; background-size:20px 20px; vertical-align:middle; margin-right:8px;} .shop-list {} .shop-list li {text-align:center;padding:20px 0;} .shop-list li p {text-align:left;color:#7A7878; text-indent:2em;} .shop-list li img {margin:0 auto;} .content-contact {color:#F15050;padding:20px 10px;line-height:30px;text-indent:2em;} .cmbc-qrcode {text-align:center;padding:20px 0;} .down-cmbc {text-align:center;display:block;margin:0 auto;} .down-cmbc img {margin:0 auto;} /*@media screen and (min-width: 480px) { .doc { font-size: 21px}}@media screen and (min-width: 640px) { .doc { font-size: 28px}}*/.list li{display:-moz-box; display:-webkit-box; display:box;}.list li p{ width:90%}.last{ text-align:right ; font-size:12px; color:#bdbdbd; padding-right:20px; margin-bottom:10px;}
这一大串,也不知道是是没意思,先用着吧。
接着就是html了:
<html>
<head>
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="file:///android_asset/mobile.css" type="text/css" rel="stylesheet">
</head>
<body>
<img src="picsample.jpg"/>
</body>
</html>
html就简单多了,增加css和图片的引用就ok了。
注:html,css,图片等文件,在这个demo中都是放在assert中的。
4.这样用那不是只能引用本地的长图了?需要显示的长图片是从服务端请求过来的呢?
这个还没有尝试过,不知道能不能去修改html里图片的引用。
5,之后同事提醒可以试一下手势缩放图片的控件。这个东西找到一个第三方开源的项目
https://codeload.github.com/jasonpolites/gesture-imageview/zip/master
有需要了再试一下吧。
android加载长图片的方法相关推荐
- android 加载大长图,android加载长图片的方法
1.很多应用都有加载一张长图片,用户可以上下拉动图片. 自己没有好的想法,那只好百度咯.结果都说用webview来实现,好吧那就只好先试一下了. 2.自己写了简单的html,然后webview加载.图 ...
- Android 加载长图片(类似微博长图)
巨图片加载,android BitmapRegionDecoder . 1.BitmapRegionDecoder.newInstance(); 2.bitmap = mDecoder.decodeR ...
- Android 系统(167)----Glide加载圆角图片的方法
Glide加载圆角图片的方法 现在在市面上很多App的UI设计都会出现圆角图片的显示.Glide本身也提供了圆角图片的加载方式.但是我们在开发中有可能遇到只要顶部展示圆角,或者某一个角是圆角.这样的需 ...
- android圆角glide,Glide加载圆角图片的方法
原标题:Glide加载圆角图片的方法 现在在市面上很多App的UI设计都会出现圆角图片的显示.Glide本身也提供了圆角图片的加载方式.但是我们在开发中有可能遇到只要顶部展示圆角,或者某一个角是圆角. ...
- android加载长图片出现Bitmap too large to be uploaded into a texture的解决方案
最近做图片预览,加载长图片的时候,出现黑屏,无法加载图片的情况,查看Log,发现报出了Bitmap too large to be uploaded into a texture的错误.(我用的是Im ...
- android 漫画加载方案,Android加载长图的多种方案分享
背景介绍 在某些特定场景下,我们需要考虑加载长图的需求,比如加载一幅<清明上河图>,这个好像有点过分了,那就加载1/2的<清明上河图>吧... 那TMD还不是一样道理. 言归正 ...
- 关于 android 加载 res 图片 out of memory 问题 解决 同样适用于 sd卡图片
2019独角兽企业重金招聘Python工程师标准>>> 发现android 加载res图片如果过多也会崩溃 android 也是使用 Bitmap bm = BitmapFacto ...
- Android手机内存图片读取,有效解决Android加载大图片内存溢出的问题
今天在交流群里,有人问我他经常遇到加载图片时内存溢出的问题,遇到的情况还是在自己的测试机或者手机里没有问题,做好了, 到了客户手机里就内存溢出了.其实有时候不同的手机和不同的系统对内存的要求不一样,尤 ...
- 【转载】Android加载大图片OOM异常解决
官方资料: https://developer.android.com/topic/performance/graphics/load-bitmap 思路 先测试未知来源图片的尺寸和MIME文件类型; ...
最新文章
- R语言使用ggplot2包的快速可视化函数qplot绘制分组直方图(分组颜色设置)实战
- stop words list
- python官方手册-Python3 中文手册
- yarn界面中的Minimum Allocation和Maximum Allocation与yarn-site.xml中参数的对应关系
- STL17-函数对象
- php mysql切换版本5.7_phpstudy里升级mysql版本到5.7
- 3-8《Ruby元编程》第二章对象模型
- Mysql事务控制语言
- LYNC功能之呼叫合并
- iptables和SELinux漫谈
- Xamarin.Forms 仿照京东搜索记录控件
- Java关键字和标识符
- mysql建表语句转换成oracle,如何手动将ORACLE的sql建表语句转换为MYSQL的建表语句...
- 软件测试工程师必备知识点
- 大学计算机考试59分,大学期末考59分,你会找老师理论吗?很多人都猜错
- 那个英雄辈出的年代——《资治通鉴》等历史札记有感2000字
- 新年新气象,2021来了,用Python换一张头像迎新年吧!
- 迸发中的小i机器人,2018年多处开花
- 做一只可爱的小猪背包 [Cover 背包九讲]
- 支付宝当面付申请设置教程,支持个人用户
热门文章
- double和int区别
- 群星灵能界所有事件_星际考古就绪《群星》剧情DLC“古代遗迹”内容公布
- 将CNN与RNN组合使用,天才还是错乱?
- 越南是下一个电商天堂——扬帆牧哲
- python尼姆游戏_使用Python编写一个聪明的尼姆游戏
- 编写递归算法,计算二叉树中叶子结点的数目
- Java菜单——设置快捷键
- 预计保持30%增速,2022年酒店该如何发力亲子游市场?
- IT项目管理之第3章 项目综合管理习题
- 爆款落幕、付费跌倒,阅文IP生意仅在“第一层“