ImageView setScaleType - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for ImageView setScaleType method.

This code example shows how to use the following methods:setLayoutParams, setPadding, setImageBitmap, setScaleType
        } 
 
        public View getView(int position, View convertView, ViewGroup parent) {
            ImageView imageView;
            if (convertView == null) {
                imageView = new ImageView(mContext);
                imageView.setLayoutParams(new GridView.LayoutParams(50, 50));
                imageView.setScaleType(ImageView.ScaleType.FIT_XY);
                imageView.setPadding(4, 4, 4, 4);
            } else { 
                imageView = (ImageView) convertView;
            } 
 
 
            imageView.setImageBitmap(emotions.get(index.get(position)));
            return imageView;
        } 
 
 
    } 
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setImageResource, setScaleType
        return position;
    } 
 
    @Override 
    public View getView(int position, View convertView, ViewGroup parent) {
        ImageView i = new ImageView(mContext);
        i.setImageResource(mImageIds[position]);
        i.setScaleType(ScaleType.CENTER_INSIDE);
        return i;
    } 
} 
9
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setBackgroundResource, setLayoutParams, setImageResource, setScaleType
        } 
 
        public View getView(int position, View convertView, ViewGroup parent) {
            ImageView imageView;
            if (convertView == null) {
                convertView = new ImageView(mContext);
 
                imageView = (ImageView) convertView;
                imageView.setScaleType(ImageView.ScaleType.FIT_XY);
                imageView.setLayoutParams(new Gallery.LayoutParams(
                        (int) (ITEM_WIDTH * mDensity + 0.5f),
                        (int) (ITEM_HEIGHT * mDensity + 0.5f)));
             
                // The preferred Gallery item background 
                imageView.setBackgroundResource(mGalleryItemBackground);
            } else { 
                imageView = (ImageView) convertView;
            } 
 
            imageView.setImageResource(mImageIds[position]);

8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setLayoutParams, setPadding, setAdjustViewBounds, setImageResource, setScaleType
This code example shows how to use the following methods:setLayoutParams, setPadding, setImageBitmap, setScaleType
	// Create the view for each user status 
	// [FIXME] Should be put as an XML file (possible?) 
	 
	private View makeUserStatusView(Context context, TwitterEntry entry) {
 
    	ImageView iv = new ImageView(context);
    	Bitmap photo = BitmapCache.getInstance().get(entry.getUser().getProfileImageURL());
 
    	iv.setImageBitmap(photo);
    	iv.setScaleType(ScaleType.CENTER);
    	iv.setPadding(0, 4, 4, 0);
    	iv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
	 
    	TextView tv = new TextView(context);
    	tv.setText(entry.getUser().getName() + ": " + entry.getText());
    	tv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
	 
    	LinearLayout layout = new LinearLayout(context);
    	layout.setOrientation(LinearLayout.HORIZONTAL);
    	layout.setPadding(4, 2, 4, 2);
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setLayoutParams, setImageDrawable, setScaleType
        mApps = getPackageManager().queryIntentActivities(mainIntent, 0);
    } 
 
    public class AppsAdapter extends BaseAdapter {
        public View getView(int position, View convertView, ViewGroup parent) {
            ImageView i = new ImageView(LayoutAnimation1.this);
 
            ResolveInfo info = mApps.get(position % mApps.size());
 
            i.setImageDrawable(info.activityInfo.loadIcon(getPackageManager()));
            i.setScaleType(ImageView.ScaleType.FIT_CENTER);
            final int w = (int) (36 * getResources().getDisplayMetrics().density + 0.5f);
            i.setLayoutParams(new GridView.LayoutParams(w, w));
            return i;
        } 
 
 
        public final int getCount() { 
            return Math.min(32, mApps.size());
        } 
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setLayoutParams, setImageDrawable, setScaleType
 
        public View getView(int position, View convertView, ViewGroup parent) {
            ImageView i;
 
            if (convertView == null) {
                i = new ImageView(Grid1.this);
                i.setScaleType(ImageView.ScaleType.FIT_CENTER);
                i.setLayoutParams(new GridView.LayoutParams(50, 50));
            } else { 
                i = (ImageView) convertView;
            } 
 
            ResolveInfo info = mApps.get(position);
            i.setImageDrawable(info.activityInfo.loadIcon(getPackageManager()));
 
            return i;
        } 
 
 
        public final int getCount() { 
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setBackgroundColor, setLayoutParams, setScaleType
 
    public void onNothingSelected(AdapterView<?> parent) {
    } 
 
    public View makeView() {
        ImageView i = new ImageView(this);
        i.setBackgroundColor(0xFF000000);
        i.setScaleType(ImageView.ScaleType.FIT_CENTER);
        i.setLayoutParams(new ImageSwitcher.LayoutParams(LayoutParams.MATCH_PARENT,
                LayoutParams.MATCH_PARENT));
        return i;
    } 
 
    private ImageSwitcher mSwitcher;
 
    public class ImageAdapter extends BaseAdapter {
        public ImageAdapter(Context c) {
            mContext = c;
        } 
 
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setLayoutParams, setImageDrawable, setScaleType
        public View getView(int position, View convertView, ViewGroup parent) {
            CheckableLayout l;
            ImageView i;
 
            if (convertView == null) {
                i = new ImageView(Grid3.this);
                i.setScaleType(ImageView.ScaleType.FIT_CENTER);
                i.setLayoutParams(new ViewGroup.LayoutParams(50, 50));
                l = new CheckableLayout(Grid3.this);
                l.setLayoutParams(new GridView.LayoutParams(GridView.LayoutParams.WRAP_CONTENT,
                        GridView.LayoutParams.WRAP_CONTENT));
                l.addView(i);
            } else { 
                l = (CheckableLayout) convertView;
                i = (ImageView) l.getChildAt(0);
            } 
 
            ResolveInfo info = mApps.get(position);
            i.setImageDrawable(info.activityInfo.loadIcon(getPackageManager()));
 

8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setId, setTag, setImageDrawable, setScaleType, setVisibility
     * Sets up the status icon, creating it if necessary. 
     */ 
    public void setStatusButton(Drawable icon, int id, long appId) {
        if (icon != null) {
            if (mStatusButton == null) {
                mStatusButton = new ImageView(mContext);
                mStatusButton.setId(id);
                mStatusButton.setScaleType(ScaleType.CENTER);
                addView(mStatusButton);
            } 
            mStatusButton.setImageDrawable(icon);
            mStatusButton.setTag(appId);
            mStatusButton.setVisibility(View.VISIBLE);
        } else { 
            if (mStatusButton != null) {
                mStatusButton.setVisibility(View.GONE);
            } 
        } 
    } 
 
8
CodeRank
Experience pair programming with AI  Get Codota for Java

Related ImageView setScaleType Questions & Answers:

Other ImageView setScaleType Examples

59:					imageWidth);
60:	
61:			imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
62:			imageView.setLayoutParams(new GridView.LayoutParams(imageWidth,
63:					imageWidth));

Read More

46:			ImageView imageView = new ImageView(mContext);
47:	        imageView.setImageResource(mThumbIds[position]);
48:	        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
49:	        imageView.setLayoutParams(new GridView.LayoutParams(70, 70));
50:	        return imageView;

Read More

24:	            imageView = new ImageView(mContext);
25:	            imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
26:	            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
27:	            imageView.setPadding(8, 8, 8, 8);
28:	        } else {

Read More

setScaleType Method Overview
Controls how the image should be resized or moved to match the size of this ImageView.
See Code Examples for other Android ImageView Methods: