Java Code Examples for android.widget.GridView#LayoutParams

The following examples show how to use android.widget.GridView#LayoutParams . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImageGridFragment.java    From graphics-samples with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the item height. Useful for when we know the column width so the height can be set
 * to match.
 *
 * @param height The item height in pixel
 */
void setItemHeight(int height) {
    if (height == mItemHeight) {
        return;
    }
    mItemHeight = height;
    mImageViewLayoutParams =
            new GridView.LayoutParams(LayoutParams.MATCH_PARENT, mItemHeight);
    mImageFetcher.setImageSize(height);
    notifyDataSetChanged();
}
 
Example 2
Source File: ImageGridFragment.java    From android-DisplayingBitmaps with Apache License 2.0 5 votes vote down vote up
public ImageAdapter(Context context) {
    super();
    mContext = context;
    mImageViewLayoutParams = new GridView.LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    // Calculate ActionBar height
    TypedValue tv = new TypedValue();
    if (context.getTheme().resolveAttribute(
            android.R.attr.actionBarSize, tv, true)) {
        mActionBarHeight = TypedValue.complexToDimensionPixelSize(
                tv.data, context.getResources().getDisplayMetrics());
    }
}
 
Example 3
Source File: GdvAdapter.java    From palmsuda with Apache License 2.0 5 votes vote down vote up
public View getView(int position, View convertView, ViewGroup parent) {
	ViewHolder holder = new ViewHolder();
	convertView = this.mInflater.inflate(R.layout.grid_icon_item, null);
	holder.tvItem = (TextView) convertView.findViewById(R.id.wap_item_name);
	holder.iView = (ImageView) convertView
			.findViewById(R.id.wap_item_image);
	holder.icView = (ImageView) convertView.findViewById(R.id.wap_ic_image);

	ModuleItem item = this.getItem(position);
	holder.tvItem.setText("" + item.getModuleName());

	if (item.getOptions().isHotModule()) {
		holder.icView.setVisibility(View.VISIBLE);
		holder.icView.setImageResource(R.drawable.icon_hot);
	} else if (item.getOptions().isNewModule()) {
		holder.icView.setVisibility(View.VISIBLE);
		holder.icView.setImageResource(R.drawable.icon_new);
	} else {
		holder.icView.setVisibility(View.GONE);
		holder.icView.setImageResource(0);
	}

	RelativeLayout.LayoutParams paLayoutParams = (LayoutParams) holder.iView
			.getLayoutParams();
	paLayoutParams.width = PalmSudaApp.SCREEN_WEIDTH * 3 / 16;
	paLayoutParams.height = paLayoutParams.width * 100 / 96;
	holder.iView.setLayoutParams(paLayoutParams);
	holder.iView.setScaleType(ScaleType.FIT_XY);
	imgeWorker.loadBitmap(item.getIconUrl(), holder.iView,
			PalmSudaApp.SCREEN_WEIDTH / 4, PalmSudaApp.SCREEN_WEIDTH / 4);

	GridView.LayoutParams lparams = new GridView.LayoutParams(
			PalmSudaApp.SCREEN_WEIDTH * 3 / 16 + 5,
			PalmSudaApp.SCREEN_WEIDTH / 4 + 10);
	convertView.setLayoutParams(lparams);
	return convertView;
}
 
Example 4
Source File: ImageGridAdapter.java    From ImageChoose with MIT License 5 votes vote down vote up
public ImageGridAdapter(Context context, boolean showCamera,boolean showTxt){
    mContext = context;
    mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    this.showCamera = showCamera;
    this.showTxt = showTxt;
    mItemLayoutParams = new GridView.LayoutParams(GridView.LayoutParams.MATCH_PARENT, GridView.LayoutParams.MATCH_PARENT);
}
 
Example 5
Source File: RoundView.java    From Android-Material-Icons with Apache License 2.0 5 votes vote down vote up
public RoundView(Context context) {
    super(context);
    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    checkedPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    checkedPaint.setColor(Color.parseColor("#FF808080"));

    int size = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 90, getResources().getDisplayMetrics());
    GridView.LayoutParams layoutParams = new GridView.LayoutParams(size, size);
    setLayoutParams(layoutParams);
}
 
Example 6
Source File: ImageAdapter.java    From Android-ImagesPickers with Apache License 2.0 5 votes vote down vote up
public void setItemSize(int columnWidth) {
    if (mItemSize == columnWidth) {
        return;
    }
    mItemSize = columnWidth;
    mItemLayoutParams = new GridView.LayoutParams(mItemSize, mItemSize);
    notifyDataSetChanged();
}
 
Example 7
Source File: ImageAdapter.java    From Android-ImagesPickers with Apache License 2.0 5 votes vote down vote up
public ImageAdapter(Context context, List<Image> imageList, ImageConfig imageConfig) {
    mLayoutInflater = LayoutInflater.from(context);
    this.context = context;
    this.imageList = imageList;
    this.imageConfig = imageConfig;
    mItemLayoutParams = new GridView.LayoutParams(GridView.LayoutParams.MATCH_PARENT, GridView.LayoutParams.MATCH_PARENT);
}
 
Example 8
Source File: ImageGridAdapter.java    From xmpp with Apache License 2.0 5 votes vote down vote up
@Override
public View getView(int i, View view, ViewGroup viewGroup) {

    int type = getItemViewType(i);
    if(type == TYPE_CAMERA){
        view = mInflater.inflate(R.layout.list_item_camera, viewGroup, false);
        view.setTag(null);
    }else if(type == TYPE_NORMAL){
        ViewHolde holde;
        if(view == null){
            view = mInflater.inflate(R.layout.list_item_image, viewGroup, false);
            holde = new ViewHolde(view);
        }else{
            holde = (ViewHolde) view.getTag();
            if(holde == null){
                view = mInflater.inflate(R.layout.list_item_image, viewGroup, false);
                holde = new ViewHolde(view);
            }
        }
        if(holde != null) {
            holde.bindData(getItem(i));
        }
    }

    /** Fixed View Size */
    GridView.LayoutParams lp = (GridView.LayoutParams) view.getLayoutParams();
    if(lp.height != mItemSize){
        view.setLayoutParams(mItemLayoutParams);
    }

    return view;
}
 
Example 9
Source File: MainGridAdapter.java    From xmpp with Apache License 2.0 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {

    if (mImages.size() != number && position >= mImages.size()) {
        convertView = mInflater.inflate(R.layout.grid_item_add, parent, false);
        convertView.setTag(null);
    } else {
        Viewholder viewholder;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.grid_item_image, parent, false);
            viewholder = new Viewholder(convertView);
        } else {
            viewholder = (Viewholder) convertView.getTag();
            if (viewholder == null) {
                convertView = mInflater.inflate(R.layout.grid_item_image, parent, false);
                viewholder = new Viewholder(convertView);
            }
        }
        if (viewholder != null) {
            viewholder.bindData(getItem(position));
        }
    }
    GridView.LayoutParams lp = (GridView.LayoutParams) convertView.getLayoutParams();
    if (lp.height != mItemSize) {
        convertView.setLayoutParams(mItemLayoutParams);
    }

    return convertView;


}
 
Example 10
Source File: ImageGridAdapter.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
@Override
public View getView(int i, View view, ViewGroup viewGroup) {

    int type = getItemViewType(i);
    if(type == TYPE_CAMERA){
        view = mInflater.inflate(R.layout.multi_image_select_list_item_camera, viewGroup, false);
        view.setTag(null);
    }else if(type == TYPE_NORMAL){
        ViewHolde holde;
        if(view == null){
            view = mInflater.inflate(R.layout.multi_image_select_list_item_image, viewGroup, false);
            holde = new ViewHolde(view);
        }else{
            holde = (ViewHolde) view.getTag();
            if(holde == null){
                view = mInflater.inflate(R.layout.multi_image_select_list_item_image, viewGroup, false);
                holde = new ViewHolde(view);
            }
        }
        if(holde != null) {
            holde.bindData(getItem(i));
        }
    }

    /** Fixed View Size */
    GridView.LayoutParams lp = (GridView.LayoutParams) view.getLayoutParams();
    if(lp.height != mItemSize){
        view.setLayoutParams(mItemLayoutParams);
    }

    return view;
}
 
Example 11
Source File: MainGridAdapter.java    From xmpp with Apache License 2.0 5 votes vote down vote up
public MainGridAdapter(Context context, Callback callback,int n) {
    mCallback = callback;
    mContext = context;
    mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mItemLayoutParams = new GridView.LayoutParams(GridView.LayoutParams.MATCH_PARENT, GridView.LayoutParams.MATCH_PARENT);
    number=n;

}
 
Example 12
Source File: ImageGridAdapter.java    From xmpp with Apache License 2.0 4 votes vote down vote up
public ImageGridAdapter(Context context, boolean showCamera){
    mContext = context;
    mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    this.showCamera = showCamera;
    mItemLayoutParams = new GridView.LayoutParams(GridView.LayoutParams.MATCH_PARENT, GridView.LayoutParams.MATCH_PARENT);
}
 
Example 13
Source File: ImageAdapter.java    From Android-ImagesPickers with Apache License 2.0 4 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {

    int type = getItemViewType(position);

    if (type == TYPE_CAMERA) {
        convertView = mLayoutInflater.inflate(R.layout.imageselector_item_camera, parent, false);
        convertView.setTag(null);
    } else if (type == TYPE_NORMAL) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = mLayoutInflater.inflate(R.layout.imageselector_item_image, parent, false);
            holder = new ViewHolder(convertView);
        } else {
            holder = (ViewHolder) convertView.getTag();
            if (holder == null) {
                convertView = mLayoutInflater.inflate(R.layout.imageselector_item_image, parent, false);
                holder = new ViewHolder(convertView);
            }
        }

        if (showSelectIndicator) {
            holder.photo_check.setVisibility(View.VISIBLE);
            if (selectedImageList.contains(getItem(position))) {
                holder.photo_check.setImageResource(R.drawable.imageselector_select_checked);
                holder.photo_mask.setVisibility(View.VISIBLE);
            } else {
                holder.photo_check.setImageResource(R.drawable.imageselector_select_uncheck);
                holder.photo_mask.setVisibility(View.GONE);
            }
        } else {
            holder.photo_check.setVisibility(View.GONE);
        }

        if (mItemSize > 0) {

            imageConfig.getImageLoader().displayImage(context, getItem(position).path, holder.photo_image);

        }
    }

    GridView.LayoutParams layoutParams = (GridView.LayoutParams) convertView.getLayoutParams();
    if (layoutParams.height != mItemSize) {
        convertView.setLayoutParams(mItemLayoutParams);
    }

    return convertView;
}
 
Example 14
Source File: PhotoAdapter.java    From PhotoPicker with Apache License 2.0 4 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if(getItemViewType(position) == TYPE_CAMERA) {
        convertView = LayoutInflater.from(mContext).inflate(
                R.layout.item_camera_layout, null);
        convertView.setTag(null);
        //设置高度等于宽度
        GridView.LayoutParams lp = new GridView.LayoutParams(mWidth, mWidth);
        convertView.setLayoutParams(lp);
    } else {
        ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(
                    R.layout.item_photo_layout, null);
            holder.photoImageView = (ImageView) convertView.findViewById(R.id.imageview_photo);
            holder.selectView = (ImageView) convertView.findViewById(R.id.checkmark);
            holder.maskView = convertView.findViewById(R.id.mask);
            holder.wrapLayout = (FrameLayout) convertView.findViewById(R.id.wrap_layout);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.photoImageView.setImageResource(R.drawable.ic_photo_loading);
        Photo photo = getItem(position);
        if(mSelectMode == PhotoPickerActivity.MODE_MULTI) {
            holder.wrapLayout.setOnClickListener(mOnPhotoClick);
            holder.photoImageView.setTag(photo.getPath());
            holder.selectView.setVisibility(View.VISIBLE);
            if(mSelectedPhotos != null && mSelectedPhotos.contains(photo.getPath())) {
                holder.selectView.setSelected(true);
                holder.maskView.setVisibility(View.VISIBLE);
            } else {
                holder.selectView.setSelected(false);
                holder.maskView.setVisibility(View.GONE);
            }
        } else {
            holder.selectView.setVisibility(View.GONE);
        }
        ImageLoader.getInstance().display(photo.getPath(), holder.photoImageView,
                mWidth, mWidth);
    }
    return convertView;
}
 
Example 15
Source File: GridViewAdapter.java    From DarkCalculator with MIT License 4 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder viewHolder;
    View view;
    if (convertView == null) {
        view = LayoutInflater.from(MainActivity.activity).inflate(layoutId, parent, false);
        viewHolder = new ViewHolder();
        viewHolder.title = (TextView) view.findViewById(R.id.text_item);
        if (viceText != null)
            viewHolder.vice = (TextView) view.findViewById(R.id.text_vice_item);
        view.setTag(viewHolder);
    } else {
        view = convertView;
        viewHolder = (ViewHolder) view.getTag();
    }

    viewHolder.title.setText(text.get(position));

    if (viceText != null) {
        viewHolder.vice.setText(viceText.get(position));
    }

    if (height == 0)
        height = gridView.getHeight();

    GridView.LayoutParams param = new GridView.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            height / rows);
    view.setLayoutParams(param);

    if (layoutId == R.layout.button_operator) {
        if (deleteParam == null)
            deleteParam = MainActivity.activity.delete.getLayoutParams();
        if (deleteParam.height != height / rows) {
            deleteParam.height = height / rows;
            MainActivity.activity.delete.setLayoutParams(deleteParam);
        }
    }

    return view;
}
 
Example 16
Source File: ImageGridFragment.java    From graphics-samples with Apache License 2.0 4 votes vote down vote up
ImageAdapter(Context context) {
    super();
    mContext = context;
    mImageViewLayoutParams = new GridView.LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
}
 
Example 17
Source File: ImageGridAdapter.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
public ImageGridAdapter(Context context, boolean showCamera){
    mContext = context;
    mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    this.showCamera = showCamera;
    mItemLayoutParams = new GridView.LayoutParams(GridView.LayoutParams.MATCH_PARENT, GridView.LayoutParams.MATCH_PARENT);
}
 
Example 18
Source File: ImageGridAdapter.java    From xmpp with Apache License 2.0 3 votes vote down vote up
/**
 * 重置每个Column的Size
 * @param columnWidth
 */
public void setItemSize(int columnWidth) {

    if(mItemSize == columnWidth){
        return;
    }

    mItemSize = columnWidth;

    mItemLayoutParams = new GridView.LayoutParams(mItemSize, mItemSize);

    notifyDataSetChanged();
}
 
Example 19
Source File: ImageGridAdapter.java    From ImageChoose with MIT License 3 votes vote down vote up
/**
 * 重置每个Column的Size
 * @param columnWidth
 */
public void setItemSize(int columnWidth) {

    if(mItemSize == columnWidth){
        return;
    }

    mItemSize = columnWidth;

    mItemLayoutParams = new GridView.LayoutParams(mItemSize, mItemSize);

    notifyDataSetChanged();
}
 
Example 20
Source File: ImageGridAdapter.java    From UltimateAndroid with Apache License 2.0 3 votes vote down vote up
/**
 * 重置每个Column的Size
 * @param columnWidth
 */
public void setItemSize(int columnWidth) {

    if(mItemSize == columnWidth){
        return;
    }

    mItemSize = columnWidth;

    mItemLayoutParams = new GridView.LayoutParams(mItemSize, mItemSize);

    notifyDataSetChanged();
}