菜单
  

    使用到BaseAdapte类的派生类GalleryAdapter,存放Gallery要显示的图片。Gallery每次切换图片,GalleryAdapter类的getView()都会被调用一次。GalleryAdapter引用的图片来源于SD卡pictures文件夹里的数据。getView()每次每次被调用时,根据position读取文件,对页面进行布局。
    使用ImageView控件的派生类BasaImageView。BasaImageView类具有调整图片居中显示和对图片进行放大、缩小功能。
    GalleryViewActivity浏览图片界面布局使用MyGallery类,通过findViewById找到控件MyGallery,调用setAdapter函数,设置适配器GalleryAdapter,并把图片地址传入适配器中。当通过点击软件功能界面的图册,跳转到GalleryViewActivity活动界面,显示图片。
    (1)    ImageView缩放
    得到图片缩放比例,把图片转换成Matrix对象,对Matrix对象进行缩放和移动。更新UI。
    protected void zoomTo(float scale, float centerX, float centerY) {
            if (scale > mMaxZoom) {
                scale = mMaxZoom;
            } else if (scale < mMinZoom) {
                scale = mMinZoom;
            }
            float oldScale = getScale();
            float deltaScale = scale / oldScale;
            mSuppMatrix.postScale(deltaScale, deltaScale, centerX, centerY);
            setImageMatrix(getImageViewMatrix());
            center(true, true);
        }
    protected void zoomTo(final float scale, final float centerX, final float centerY, final float durationMs) {
            final float incrementPerMs = (scale - getScale()) / durationMs;
            final float oldScale = getScale();
            final long startTime = System.currentTimeMillis();
            mHandler.post(new Runnable() {
                public void run() {
                    long now = System.currentTimeMillis();
                    float currentMs = Math.min(durationMs, now - startTime);
                    float target = oldScale + (incrementPerMs * currentMs);
                    zoomTo(target, centerX, centerY);
                    if (currentMs < durationMs) {
                        mHandler.post(this);
                    }
                }
            });
        }
    protected void zoomTo(float scale) {
            float cx = getWidth() / 2F;
            float cy = getHeight() / 2F;

            zoomTo(scale, cx, cy);
        }
    protected void zoomToPoint(float scale, float pointX, float pointY) {
            float cx = getWidth() / 2F;
            float cy = getHeight() / 2F;

            panBy(cx - pointX, cy - pointY);
            zoomTo(scale, cx, cy);
        }
    (2)    双击缩放图片
  1. 上一篇:超市库存系统的国内外研究现状和发展趋势
  2. 下一篇:JSP+mysql药品销售及管理系统设计与实现+用例图
  1. JAVA基于安卓平台的医疗护工管理系统设计

  2. 基于Hadoop的制造过程大数据存储平台构建

  3. php+mysql志愿者服务平台前端页面设计

  4. 《网站设计与管理》课程...

  5. Justep基于开放平台的企业...

  6. 基于IOS的游戏资讯平台的设计与实现

  7. android学习行为共享系统的设计与实现

  8. 中考体育项目与体育教学合理结合的研究

  9. 十二层带中心支撑钢结构...

  10. 河岸冲刷和泥沙淤积的监测国内外研究现状

  11. 乳业同业并购式全产业链...

  12. java+mysql车辆管理系统的设计+源代码

  13. 大众媒体对公共政策制定的影响

  14. 当代大学生慈善意识研究+文献综述

  15. 杂拟谷盗体内共生菌沃尔...

  16. 电站锅炉暖风器设计任务书

  17. 酸性水汽提装置总汽提塔设计+CAD图纸

  

About

751论文网手机版...

主页:http://www.751com.cn

关闭返回