Example usage for android.widget ImageView ImageView

List of usage examples for android.widget ImageView ImageView

Introduction

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

Prototype

public ImageView(Context context) 

Source Link

Usage

From source file:com.fuzz.emptyhusk.prefab.InlineAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    int resId = (position % 3 == 0) ? R.drawable.rectangle_wide_secondary : R.drawable.rectangle_wide_tertiary;

    ImageView inflated = new ImageView(container.getContext());
    inflated.setImageResource(resId);// w  w  w.  ja  v a 2  s  .co m
    container.addView(inflated);

    viewCache.put(position, inflated);

    return inflated;
}

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

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

    try {//from w  w  w. j a va  2 s .c  o  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:io.github.importre.android.chromeadb.ChromeAdbService.java

private void addMouseCursor() {
    if (mCursorImage == null) {
        mCursorImage = new ImageView(this);
        mCursorImage.setImageResource(R.drawable.cursor);
    }// w  w  w .ja  v a  2 s .com

    if (mLayoutParam == null) {
        mLayoutParam = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
                WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
                        | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
                PixelFormat.TRANSLUCENT);
        mLayoutParam.gravity = Gravity.LEFT | Gravity.TOP;
        mLayoutParam.flags |= WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
    }

    if (mWindowManager == null) {
        mWindowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
        mWindowManager.addView(mCursorImage, mLayoutParam);
    }
}

From source file:com.asc_ii.bangnote.bigbang.BigBangActionBar.java

private void initSubViews() {
    Context context = getContext();

    mBorder = ContextCompat.getDrawable(context, R.drawable.bigbang_action_bar_bg);
    mBorder.setCallback(this);

    mSearch = new ImageView(context);
    mSearch.setImageResource(R.mipmap.bigbang_action_search);
    mSearch.setOnClickListener(this);
    mShare = new ImageView(context);
    mShare.setImageResource(R.mipmap.bigbang_action_share);
    mShare.setOnClickListener(this);
    mCopy = new ImageView(context);
    mCopy.setImageResource(R.mipmap.bigbang_action_copy);
    mCopy.setOnClickListener(this);

    addView(mSearch, createLayoutParams());
    addView(mShare, createLayoutParams());
    addView(mCopy, createLayoutParams());

    setWillNotDraw(false);//from   www.j a v  a  2s  . co  m

    mActionGap = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 15,
            getResources().getDisplayMetrics());
    mContentPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10,
            getResources().getDisplayMetrics());
}

From source file:com.tony.babygo.adapter.ImagePagerAdapter.java

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

    Business business = businesses.getBusinesses().get(position);
    Bitmap bitmap = Bimp.getBitmapFromMemoryCache(business.getPhoto_url());
    if (bitmap != null) {
        imageView.setImageBitmap(bitmap);
    } else {/*from ww  w .  j a va 2  s.  co m*/
        imageView.setImageResource(imageIdList.get(0));
    }

    ((ViewPager) container).addView(imageView, 0);
    imageView.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent goBrowserIntent = new Intent(context, MyBrowserActivity.class);
            goBrowserIntent.putExtra("html5url",
                    businesses.getBusinesses().get(DianpingUserData.cur_scroll_page_index).getBusiness_url());
            context.startActivity(goBrowserIntent);
        }
    });
    return imageView;
}

From source file:net.evecom.androidecssp.activity.EmergencyNotification.java

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

    //1/*from  w ww.j a  v  a  2 s  . c  om*/
    viewpager = (ViewPager) findViewById(R.id.my_viewpager_id);
    //4DepthPageTransformer
    //      viewpager.setPageTransformer(true, new DepthPageTransformer());
    viewpager.setPageTransformer(true, new RotateDownTransformer());
    //2
    viewpager.setAdapter(new PagerAdapter() {
        @Override //item   page
        public Object instantiateItem(ViewGroup container, int position) {
            //    switchpage
            ImageView imageView = new ImageView(EmergencyNotification.this);
            imageView.setImageResource(imagesId[position]);
            //
            imageView.setScaleType(ScaleType.CENTER_CROP);

            //imageViewcontainer  page
            container.addView(imageView);
            //imageViewlist
            imageViews.add(imageView);
            //imageView
            return imageView;
        }

        @Override //destroyItem
        public void destroyItem(ViewGroup container, int position, Object object) {
            container.removeView(imageViews.get(position));
        }

        @Override //  adapter
        public boolean isViewFromObject(View view, Object object) {
            return view == object;
        }

        @Override //
        public int getCount() {
            return imagesId.length;
        }
    });

}

From source file:com.commonsware.android.preso.slides.SlidesAdapter.java

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

    page.setImageResource(getPageResource(position));
    container.addView(page, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    return (page);
}

From source file:com.github.andrewlord1990.snackbarbuilder.SnackbarIconBuilder.java

ImageView bindToSnackbar() {
    LayoutParams params = getIconViewLayoutParams();
    if (iconView == null) {
        iconView = new ImageView(snackbar.getView().getContext());
        iconView.setId(R.id.snackbarbuilder_icon);

        SnackbarLayout view = (SnackbarLayout) snackbar.getView();
        view.addView(iconView, 0);//from   ww w  .j  a v a 2  s  . co m
    }
    iconView.setLayoutParams(params);
    iconView.setImageDrawable(icon);
    return iconView;
}

From source file:library.internal.IndicatorLayout.java

public IndicatorLayout(Context context, PullToRefreshBase.Mode mode) {
    super(context);
    mArrowImageView = new ImageView(context);

    Drawable arrowD = ContextCompat.getDrawable(context, R.drawable.indicator_arrow);
    mArrowImageView.setImageDrawable(arrowD);

    final int padding = getResources().getDimensionPixelSize(R.dimen.indicator_internal_padding);
    mArrowImageView.setPadding(padding, padding, padding, padding);
    addView(mArrowImageView);//from  w  w  w . j a  v a 2  s  .com

    int inAnimResId, outAnimResId;
    switch (mode) {
    case PULL_FROM_END:
        inAnimResId = R.anim.slide_in_from_bottom;
        outAnimResId = R.anim.slide_out_to_bottom;
        setBackgroundResource(R.drawable.indicator_bg_bottom);

        // Rotate Arrow so it's pointing the correct way
        mArrowImageView.setScaleType(ScaleType.MATRIX);
        Matrix matrix = new Matrix();
        matrix.setRotate(180f, arrowD.getIntrinsicWidth() / 2f, arrowD.getIntrinsicHeight() / 2f);
        mArrowImageView.setImageMatrix(matrix);
        break;
    default:
    case PULL_FROM_START:
        inAnimResId = R.anim.slide_in_from_top;
        outAnimResId = R.anim.slide_out_to_top;
        setBackgroundResource(R.drawable.indicator_bg_top);
        break;
    }

    mInAnim = AnimationUtils.loadAnimation(context, inAnimResId);
    mInAnim.setAnimationListener(this);

    mOutAnim = AnimationUtils.loadAnimation(context, outAnimResId);
    mOutAnim.setAnimationListener(this);

    final Interpolator interpolator = new LinearInterpolator();
    mRotateAnimation = new RotateAnimation(0, -180, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    mRotateAnimation.setInterpolator(interpolator);
    mRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION);
    mRotateAnimation.setFillAfter(true);

    mResetRotateAnimation = new RotateAnimation(-180, 0, Animation.RELATIVE_TO_SELF, 0.5f,
            Animation.RELATIVE_TO_SELF, 0.5f);
    mResetRotateAnimation.setInterpolator(interpolator);
    mResetRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION);
    mResetRotateAnimation.setFillAfter(true);

}

From source file:com.ouyangzn.github.utils.UiUtils.java

/**
 * toolbar//from   www  . ja  va2  s  .  co m
 *
 * @param toolbar toolbar
 * @param resId ?id
 * @param gravity ?{@link Gravity#LEFT}?{@link Gravity#RIGHT}
 * @param margin ?{@link Toolbar.LayoutParams#setMargins(int, int, int, int)}
 * @return ImageView
 */
public static ImageView addImage2Toolbar(Toolbar toolbar, int resId, int gravity, int[] margin) {
    Context context = toolbar.getContext();
    ImageView img = new ImageView(context);
    img.setImageResource(resId);
    img.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    Toolbar.LayoutParams params = new Toolbar.LayoutParams(Toolbar.LayoutParams.WRAP_CONTENT,
            Toolbar.LayoutParams.WRAP_CONTENT);
    params.gravity = gravity | Gravity.CENTER;
    try {
        params.setMargins(margin[0], margin[1], margin[2], margin[3]);
    } catch (Exception e) {
        int margin_15 = ScreenUtils.dp2px(context, 15);
        params.setMargins(margin_15, 0, margin_15, 0);
    }
    img.setLayoutParams(params);
    toolbar.addView(img);
    return img;
}