如何放大图库?

时间:2011-12-06 11:43:16

标签: android

我有自定义网页浏览的图库。我的适配器:

public class AddImgAdp extends BaseAdapter {
    int GalItemBg;
    private Context cont;

    public AddImgAdp(Context c) {
        cont = c;
        TypedArray typArray = obtainStyledAttributes(R.styleable.GalleryTheme);
        GalItemBg = typArray.getResourceId(R.styleable.GalleryTheme_android_galleryItemBackground, 0);
        typArray.recycle();
    }

    public int getCount() {
        return pagesArray.length;
    }

    public Object getItem(int position) {
        return pagesArray[position];
    }

    public long getItemId(int position) {
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {

        final WebView wView = pagesArray[position];
        if(wView!=null){
            if(wView.loaded==0){
                wView.setInitialScale(50);
                wView.getSettings().setJavaScriptEnabled(true);
                wView.getSettings().setSupportZoom(false);
                wView.getSettings().setBuiltInZoomControls(false);
                wView.getSettings().setUseWideViewPort(true);
                wView.setPadding(0, 0, 0, 0);

                wView.setWebViewClient(new WebViewClient() {
                    @Override
                    public void onReceivedError(WebView view, int errorCode, String description, String failingUrl){
                        super.onReceivedError(view, errorCode, description, failingUrl);
                    }

                    @Override
                    public boolean shouldOverrideUrlLoading(WebView view, String url){
                        view.loadUrl(url);
                        return true;
                    }

                    @Override
                    public void onPageFinished(WebView view, String url){
                        wView.loaded = 1;
                    }

                });

                wView.loadUrl(URL_TO_LOAD);
                wView.setBackgroundResource(GalItemBg);
                Gallery.LayoutParams params = new Gallery.LayoutParams(400, 430);
                wView.setLayoutParams(params);
            }
        }
        return wView;

    }

}

并且,如何以这样的方式实现缩放图库,以便所有整体都会增加/减少?

2 个答案:

答案 0 :(得分:1)

没有允许您使用imageview或图库执行此操作的功能。

但这是一个很好的教程,可以帮助你顺利上路。

Pinch zoom

答案 1 :(得分:0)

我尝试过使用viewflipper,为什么不尝试这样。我在这里粘贴了我的代码  http://www.anddev.org/code-snippets-for-android-f33/horizontal-grid-view-in-android-t56753.html