我已经从模拟器的SD卡中恢复了图像并添加到我的网格视图中。但是它们没有以正确的方式显示。![在此处输入图像描述] [1]
你能帮我吗? 我也发布了我的ImageAdapter.java 请建议任何变化.. 感谢public class ImageAdapter extends BaseAdapter
{
ArrayList<Images> array=new ArrayList<Images>();
Context mContext;
private LayoutInflater mInflater;
public ImageAdapter(Context c,ArrayList<Images> arr)
{
mContext = c;
array=arr;
mInflater = LayoutInflater.from(mContext);
Log.e("","adapter con");
}
public int getCount()
{
Log.e("Count",""+array.size());
return array.size();
}
public Object getItem(int index)
{
//return 0;
return array.get(index);
}
public long getItemId(int index)
{
return index;
}
public View getView(int position, View convertView, ViewGroup parent) {
// RelativeLayout.LayoutParams layoutParams =new //RelativeLayout.LayoutParams(30, 30);
ImageView imageView = new ImageView(mContext);
Images i=array.get(position);
imageView.setImageBitmap(i.getBitmap());
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
imageView.animate();
// imageView.setLayoutParams(layoutParams);
return imageView;
}
}
答案 0 :(得分:0)
您已定义布局参数 LayoutParam layoutparam = new LayoutParams(LayoutParams.FILL_Parent,LayoutParams.FILL_Parent); imageView.setLayoutParams(的LayoutParams);
答案 1 :(得分:0)
试试这个。这应该有效,
imageView = new ImageView(mContext);
imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);