Example usage for android.widget ImageView setScaleType

List of usage examples for android.widget ImageView setScaleType

Introduction

In this page you can find the example usage for android.widget ImageView setScaleType.

Prototype

public void setScaleType(ScaleType scaleType) 

Source Link

Document

Controls how the image should be resized or moved to match the size of this ImageView.

Usage

From source file:com.microsoft.filediscovery.adapters.DisplayFileItemAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    ImageView imageView = new ImageView(mActivity);

    try {// w w  w.ja va 2 s  .co m
        imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        imageView.setImageBitmap(mResizer.getBitmapFrom(mData.get(position)));
        ((ViewPager) container).addView(imageView, 0);
    } catch (Exception e) {
        Log.e("Asset", e.getMessage());
    }
    return imageView;
}

From source file:com.pixate.freestyle.MainFrameActivity.java

/**
 * Convenient method to add a tab to the tab widget at bottom.
 * //  w  w  w.ja  v  a  2s .c o  m
 * @param resId The resource id of image shown on indicator
 * @param content The class type of content
 */
private void addTab(int resId, Class<? extends Fragment> content) {
    ImageView indicator = new ImageView(this);
    indicator.setScaleType(ScaleType.CENTER_INSIDE);
    indicator.setBackgroundResource(R.drawable.tab_bg);
    indicator.setImageResource(resId);
    TabSpec spec = tabHost.newTabSpec(content.getSimpleName()).setIndicator(indicator);
    tabHost.addTab(spec, content, null);
}

From source file:com.blackmoon.english.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    initRecyclerView();// www.j  a  v  a 2  s .c  o m
    initToolbar();
    setupDrawerLayout();

    content = findViewById(R.id.content);

    final ImageView avatar = (ImageView) findViewById(R.id.avatar);
    avatar.setScaleType(ImageView.ScaleType.CENTER_CROP);
    avatar.setImageResource(R.drawable.listening_english);
}

From source file:com.android.ted.sample.viewpager.MainPagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    View itemView;/*from www .  j  ava 2  s. co  m*/
    Girl girl = mAllGirlList.get(position);
    if (mAllImageMap.containsKey(position)) {
        View oldView = mAllImageMap.get(position);
        Object tag = oldView.getTag();
        if (null != tag && tag instanceof Girl) {
            if (tag.equals(girl)) {
                itemView = oldView;
                container.addView(itemView);
                return itemView;
            }
        }
        container.removeView(oldView);
        mAllImageMap.remove(position);
    }

    ImageView imageView = new ImageView(mContext);
    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    Glide.with(mContext).load(girl.getImageUrl()).into(imageView);
    imageView.setTag(girl);
    ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    imageView.setLayoutParams(layoutParams);
    mAllImageMap.put(position, imageView);
    itemView = imageView;
    itemView.setOnClickListener(this);
    container.addView(itemView);
    return itemView;
}

From source file:com.ayo.opensource.zlayout.MainPagerAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    View itemView;//from   w ww .j ava2  s.  c  o m
    Girl girl = mAllGirlList.get(position);
    if (mAllImageMap.containsKey(position)) {
        View oldView = mAllImageMap.get(position);
        Object tag = oldView.getTag();
        if (null != tag && tag instanceof Girl) {
            if (tag.equals(girl)) {
                itemView = oldView;
                container.addView(itemView);
                return itemView;
            }
        }
        container.removeView(oldView);
        mAllImageMap.remove(position);
    }

    ImageView imageView = new ImageView(mContext);
    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    VanGogh.paper(imageView).paintMiddleImage(girl.getImageUrl(), null, null);
    //Glide.with(mContext).load(girl.getImageUrl()).into(imageView);
    imageView.setTag(girl);
    ViewGroup.LayoutParams layoutParams = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    imageView.setLayoutParams(layoutParams);
    mAllImageMap.put(position, imageView);
    itemView = imageView;
    itemView.setOnClickListener(this);
    container.addView(itemView);
    return itemView;
}

From source file:net.potterpcs.recipebook.PhotoEditor.java

void changeImage(String uri) {
    // Change the recipe's image. We have to do a lot of work to get
    // a bitmap that won't break Android's memory limits, but that's
    // all hidden away in the loader method. We do still have to set
    // the scaling method here, so that the image fits on the screen.
    ImageView iv = (ImageView) getActivity().findViewById(R.id.photoeditphoto);
    iv.setScaleType(ScaleType.CENTER_INSIDE);
    RecipeBook.setImageViewBitmapDecoded(getActivity(), iv, uri);
    //      Log.v(TAG, uri == null ? "no image" : uri);
    photo = uri;/* w w w.j  a v a  2  s .  com*/
}

From source file:edu.ucsb.cs.cs185.inspirante.Inbox.InboxActivity.java

protected void startDetailDialog(int position) {
    Bundle arguments = new Bundle();
    arguments.putInt("CARD_INDEX", position);
    arguments.putString("FROM", "GRID");

    DetailBlurDialog fragment = new DetailBlurDialog();

    fragment.setArguments(arguments);/*from  w  w  w  .  j  av  a 2  s  . co  m*/
    FragmentManager ft = getSupportFragmentManager();

    fragment.show(ft, "dialog");

    Bitmap map = takeScreenShot(mInboxActivity);
    Bitmap fast = CardsFragment.BlurBuilder.blur(mInboxActivity, map);
    final Drawable draw = new BitmapDrawable(getResources(), fast);

    ImageView background = (ImageView) findViewById(R.id.activity_background);
    background.bringToFront();
    background.setScaleType(ImageView.ScaleType.FIT_XY);
    background.setImageDrawable(draw);
}

From source file:com.jaspersoft.android.jaspermobile.util.resource.viewbinder.ReportResourceBinder.java

@Override
public void setThumbnail(ImageView imageView, JasperResource jasperResource) {
    imageView.setBackgroundResource(R.drawable.bg_gradient_grey);
    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    loadFromNetwork(imageView, jasperResource, getDisplayImageOptions(R.drawable.im_thumbnail_report));
}

From source file:com.cleanwiz.applock.ui.activity.StepActivity.java

private void initPoints(int pagers) {

    layout_points = (LinearLayout) findViewById(R.id.layout_point);
    layout_points.removeAllViews();//w w w .j  a  v  a  2  s .c  o m
    points = new ArrayList<ImageView>();
    int width = ScreenUtil.dip2px(mContext, 24);
    int height = ScreenUtil.dip2px(mContext, 16);
    for (int i = 0; i < pagers; i++) {
        ImageView iv = new ImageView(mContext);
        iv.setScaleType(ScaleType.CENTER_INSIDE);
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(width, height);
        if (i == 0) {
            iv.setImageResource(R.drawable.pager_point_white);
        } else {
            iv.setImageResource(R.drawable.pager_point_green);
        }
        layout_points.addView(iv, lp);
        points.add(iv);
    }

}

From source file:com.jaspersoft.android.jaspermobile.util.resource.viewbinder.ReportResourceBinder.java

@Override
public void setIcon(ImageView imageView, JasperResource jasperResource) {
    imageView.setBackgroundResource(R.drawable.bg_resource_icon_grey);
    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    loadFromNetwork(imageView, jasperResource, getDisplayImageOptions(R.drawable.ic_report));
}