【问题标题】:How to zoom in gallery?如何放大画廊?
【发布时间】:2023-03-18 01:00:01
【问题描述】:

我有带有自定义 Web 视图的图库。我的适配器:

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;

    }

}

还有,如何实现画廊的放大,使整体增加/减少?

【问题讨论】:

标签: android


【解决方案1】:

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

【讨论】:

    【解决方案2】:

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

    但这里有一个很好的教程,可以帮助你上路。

    Pinch zoom

    【讨论】:

      猜你喜欢
      • 2012-11-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-05
      • 2021-05-24
      相关资源
      最近更新 更多