使用到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)    双击缩放图片
上一篇:超市库存系统的国内外研究现状和发展趋势
下一篇:JSP+mysql药品销售及管理系统设计与实现+用例图

Android手机考勤平台的设计与实现

基于android的环境信息管理系统设计

Python+mysql宠物领养平台的设计与实现

Android全国天气移动终端应用程序设计研究

基于MOODLE平台的在线交互式学习设计

Android员工请假系统设计

Android手机考勤系统设计

基于Joomla平台的计算机学院网站设计与开发

从政策角度谈黑龙江對俄...

酵母菌发酵生产天然香料...

浅谈高校行政管理人员的...

压疮高危人群的标准化中...

浅论职工思想政治工作茬...

AES算法GPU协处理下分组加...

上海居民的社会参与研究

STC89C52单片机NRF24L01的无线病房呼叫系统设计

提高教育质量,构建大學生...