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.HumanDecisionSupportSystemsLaboratory.DD_P2P.ImageFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    iv = new ImageView(getActivity());
    byte[] icon = getArguments().getByteArray(EXTRA_IMAGE_BYTE_ARRAY);
    Bitmap bmp = BitmapFactory.decodeByteArray(icon, 0, icon.length - 1);
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    iv.setLayoutParams(params);//from ww  w  . jav  a  2  s  .  c om
    iv.setImageBitmap(bmp);
    return iv;
}

From source file:com.example.saf.LocationMapFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    imageView = new ImageView(getActivity());
    imageView.setScaleType(CENTER_INSIDE);
    eventBus = EventBusManager.getInstance();
    return imageView;
}

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

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

    // 1//from   w  w w. j a  va 2 s. c o m
    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:cn.djangoogle.pull2load.internal.IndicatorLayout.java

public IndicatorLayout(Context context, Pull2LoadBase.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);/* ww  w. j a  v  a2s  . c  o m*/

    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.manning.androidhacks.hack028.adapter.ImageAdapter.java

public View getView(int position, View convertView, ViewGroup parent) {
    ImageView imageView = new ImageView(mContext);

    imageView.setImageResource(mImageIds[position]);
    imageView.setLayoutParams(new Gallery.LayoutParams(150, 100));
    imageView.setScaleType(ImageView.ScaleType.FIT_XY);

    return imageView;
}

From source file:ir.besteveryeverapp.ui.Cells.DrawerProfileCell.java

public DrawerProfileCell(Context context) {
    super(context);
    setBackgroundColor(//0xff4c84b5
            SkinMan.currentSkin.actionbarColor());

    shadowView = new ImageView(context);
    shadowView.setVisibility(INVISIBLE);
    shadowView.setScaleType(ImageView.ScaleType.FIT_XY);
    shadowView.setImageResource(R.drawable.bottom_shadow);
    addView(shadowView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 70, Gravity.LEFT | Gravity.BOTTOM));

    avatarImageView = new BackupImageView(context);
    avatarImageView.getImageReceiver().setRoundRadius(AndroidUtilities.dp(32));
    addView(avatarImageView, LayoutHelper.createFrame(64, 64, Gravity.LEFT | Gravity.BOTTOM, 16, 0, 0, 67));
    if (SkinMan.currentSkin.hideDrawerProfile())
        avatarImageView.setVisibility(GONE);

    nameTextView = new TextView(context);
    nameTextView.setTypeface(FontManager.instance().getTypeface());
    nameTextView.setTextColor(0xffffffff);
    nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
    nameTextView.setTypeface(FontManager.instance().getTypeface());
    nameTextView.setLines(1);/*from   w  w w.j a v  a  2  s.com*/
    nameTextView.setMaxLines(1);
    nameTextView.setSingleLine(true);
    nameTextView.setGravity(Gravity.LEFT);
    nameTextView.setEllipsize(TextUtils.TruncateAt.END);
    addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT,
            Gravity.LEFT | Gravity.BOTTOM, 16, 0, 16, 28));

    phoneTextView = new TextView(context);
    phoneTextView.setTypeface(FontManager.instance().getTypeface());
    phoneTextView.setTextColor(0xffc2e5ff);
    phoneTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
    phoneTextView.setLines(1);
    phoneTextView.setMaxLines(1);
    phoneTextView.setSingleLine(true);
    phoneTextView.setGravity(Gravity.LEFT);
    addView(phoneTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT,
            Gravity.LEFT | Gravity.BOTTOM, 16, 0, 16, 9));
}

From source file:com.commonsware.cwac.cam2.support.ConfirmationFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    iv = new ImageView(getActivity());

    if (imageContext != null) {
        loadImage();/*from   ww  w.  j a  v  a2s.  co  m*/
    }

    return (iv);
}

From source file:com.cmput301.recipebot.ui.adapters.ImagePagerAdapter.java

@Override
public Object instantiateItem(ViewGroup view, int position) {
    final ImageView imageView = new ImageView(mContext);
    String image = mImages.get(position);
    ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    imageView.setLayoutParams(lp);/*w ww .j a  v  a2  s  . c o m*/
    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    if (image.startsWith("http")) {
        ImageLoader.getInstance().displayImage(image, imageView);
    } else {
        new BitmapUtils.DecodeBitmapTask(imageView).execute(image);
    }
    ((ViewPager) view).addView(imageView, 0);
    return imageView;
}

From source file:com.temboo.example.YouTubeResultView.java

public YouTubeResultView(Context context, String title, String url, String thumbnailURL) {
    super(context);
    super.setOrientation(HORIZONTAL);

    // Create the link text view, and make the link clickable
    linkView = new TextView(getContext());
    linkView.setMovementMethod(LinkMovementMethod.getInstance());

    // Set the link text
    linkView.append(Html.fromHtml("<a href='" + url + "'>" + title + "</a>"));

    // Populate the image view
    try {/* w w w. j a v  a 2 s.  com*/
        imageView = new ImageView(getContext());
        imageView.setPadding(4, 4, 4, 0);
        fetchDrawableOnThread(thumbnailURL, imageView);
        super.addView(imageView);
    } catch (Exception e) {
        Toast.makeText(getContext(), "An error occurred retrieving the video thumbnail", Toast.LENGTH_LONG)
                .show();
    }
    super.addView(linkView);
}

From source file:com.dldzkj.app.renxing.SplashActivity.java

private void initView() {
    vp = (ViewPager) findViewById(R.id.viewPager);
    ViewGroup group = (ViewGroup) findViewById(R.id.viewGroup);
    //?ID/*from  w w  w  .j  a v  a  2s.  co  m*/
    imgIdArray = new int[] { R.drawable.w1, R.drawable.w2, R.drawable.w3 };
    tips = new ImageView[imgIdArray.length];
    for (int i = 0; i < tips.length; i++) {
        ImageView imageView = new ImageView(this);
        imageView.setLayoutParams(new ViewGroup.LayoutParams(10, 10));
        tips[i] = imageView;
        if (i == 0) {
            tips[i].setBackgroundResource(R.drawable.dot_focus);
        } else {
            tips[i].setBackgroundResource(R.drawable.dot_blur);
        }

        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
        layoutParams.leftMargin = 15;
        layoutParams.rightMargin = 15;
        layoutParams.bottomMargin = 20;
        group.addView(imageView, layoutParams);
    }
    //
    mImageViews = new ImageView[imgIdArray.length];
    for (int i = 0; i < mImageViews.length; i++) {
        ImageView imageView = new ImageView(this);
        mImageViews[i] = imageView;
        imageView.setBackgroundResource(imgIdArray[i]);
    }
    mImageViews[mImageViews.length - 1].setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(SplashActivity.this, EnterActivity.class));
            finish();
        }
    });

    //Adapter
    vp.setAdapter(new MyAdapter());
    //??
    vp.setOnPageChangeListener(this);
    //ViewPager, 100??
    vp.setCurrentItem(0);

}