imageView Android的分辨率错误

imageView Android的分辨率错误,android,imageview,resolution,Android,Imageview,Resolution,我的应用程序中有一个图库,但当我加载图片时,我的分辨率与下图相同。这些图像的分辨率为300x300。即使提高分辨率,这些图像也会显示相同的分辨率 你能帮我吗 我的适配器 public class ImageAdapter extends BaseAdapter { int mGalleryItemBackground; private Context mContext; private Activity activity; priv

我的应用程序中有一个图库,但当我加载图片时,我的分辨率与下图相同。这些图像的分辨率为300x300。即使提高分辨率,这些图像也会显示相同的分辨率

你能帮我吗

我的适配器

public class ImageAdapter extends BaseAdapter {
       int mGalleryItemBackground;
        private Context mContext;
        private Activity activity;
        private ArrayList<String>  urls; 
        private ImageLoader imageLoader;
        private int largura;
        private int altura;

        public ImageAdapter(Activity acivity,Context c,ArrayList<String> urls,int largura, int altura) {
            this.activity = acivity;
            this.urls = urls;
            this.largura = largura;
            this.altura = altura;
            mContext = c;
            TypedArray a = mContext.obtainStyledAttributes(R.styleable.MapAttrs);
            mGalleryItemBackground = a.getResourceId(
                    R.styleable.HelloGallery_android_galleryItemBackground, 0);
            a.recycle();
            imageLoader=new ImageLoader(activity.getApplicationContext());
        }

        public int getCount() {
            return urls.size();
        }

        public Object getItem(int position) {
            return position;
        }

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

        public View getView(int position, View convertView, ViewGroup parent) {
            int largura = this.largura;
            int altura = this.altura/3;
            ImageView i = null;
            if(convertView == null)
                i = new ImageView(mContext);

            //i.setImageResource(mImageIds[position]);
            i.setDrawingCacheQuality(100);
            i.setScaleType(ImageView.ScaleType.FIT_XY);
            i.setBackgroundResource(mGalleryItemBackground);
            //i.setLayoutParams(new Gallery.LayoutParams(largura,altura));
            i.getLayoutParams().height = 300;
            i.getLayoutParams().width = 300;

            imageLoader.DisplayImage(urls.get(position), i);

            return i;
        }


    }
布局

<Gallery
android:id="@+id/gallery"                           android:layout_width="match_parent"                         android:layout_height="wrap_content"                            android:paddingTop="5sp"
/>

这可能是因为增加了照片所在版面的高度和宽度,或者版面的宽度和高度值不变,无法调整大小。请尝试设置版面宽度和高度以包装内容,并请粘贴代码,因为没有您的代码,任何人都无法帮助您

编辑:

将布局粘贴到xml中

其他:

如果你想让画廊里有很多照片,不要为每个元素创建新的ImageView,这样做吧

if(convertView == null)
convertView = new ImageView();
这样做是为了不在内存中保留太多的元素,并使用其他现在不可见的元素

另一方面,如果你有很多图像,你的应用程序将无法顺利运行

编辑:

您应该在DisplayImage方法中这样做

imageView.setImageBitmap(Bitmap.createScaledBitmap(bitmap, 300, 300, false));

而且它应该可以工作

在没有看到您的代码的情况下,我们如何帮助您?至少显示您定义这些维度的位置。我做了更改,但图像的大小仍然相同。如何获得mGalleryItemBackground对象可以粘贴代码吗?也许你应该尝试i.setBackgroundDrawable(背景)请将代码粘贴到你得到mGalleryItemBackground对象的地方。我认为您应该将其强制转换为drawable,然后可能会调整其大小;如果(convertView==null)i=newImageView(mContext);这就是为什么您有空指针:)将i更改为convertView并删除ImageView i=null;线条图像继续使用相同的分辨率。。。字节的大小增加了,但分辨率相同。。。。
imageView.setImageBitmap(Bitmap.createScaledBitmap(bitmap, 300, 300, false));