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.timothy.android.api.fragment.PageFragmentNew.java

public void setAllComponent(List<HtmlCleanAPI.HtmlContent> hcList) {
    Log.i(LOG_TAG, "setAllComponent()...");
    for (HtmlCleanAPI.HtmlContent hc : hcList) {
        String tag = hc.getTag();
        String content = hc.getContent();
        if (StringUtil.isEmpty(content))
            continue;

        String contentMBlank = StringUtil.mergeBlank(content);
        if (StringUtil.isEmpty(contentMBlank))
            continue;

        String contentRBlank = StringUtil.rmvEnter(StringUtil.trim(contentMBlank));
        if (StringUtil.isEmpty(contentRBlank))
            continue;

        String contentRSpecial = StringUtil.rmvSpecial(contentRBlank);
        if (StringUtil.isEmpty(contentRSpecial))
            continue;

        Log.i(LOG_TAG, "tag:" + tag);
        Log.i(LOG_TAG, "content:" + contentRSpecial);

        if (tag.equalsIgnoreCase("P")) {
            final TextView tagPTV = new TextView(mContext);
            tagPTV.setBackgroundResource(R.drawable.tag_p_drawable);
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.WRAP_CONTENT);
            lp.setMargins(2, 3, 2, 3);/*from   w  ww  .  jav a 2  s .  c  om*/
            tagPTV.setLayoutParams(lp);
            tagPTV.setPadding(3, 3, 3, 3);
            tagPTV.setPaddingRelative(3, 3, 3, 3);
            tagPTV.setMovementMethod(ScrollingMovementMethod.getInstance());
            tagPTV.setTextColor(Color.BLACK);
            tagPTV.setText(contentRSpecial);
            tagPTV.setTextSize(TEXT_SIZE);
            tagPTV.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    openDialog(tagPTV.getText().toString());
                    return false;
                }
            });
            lineLayout.addView(tagPTV);

        } else if (tag.equalsIgnoreCase("pre")) {
            final TextView tagPre = new TextView(mContext);
            tagPre.setBackgroundColor(Color.parseColor("#D2EADE"));
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.WRAP_CONTENT);
            lp.setMargins(2, 2, 2, 2);
            tagPre.setLayoutParams(lp);
            tagPre.setPadding(2, 2, 2, 2);
            tagPre.setPaddingRelative(2, 2, 2, 2);
            tagPre.setMovementMethod(ScrollingMovementMethod.getInstance());
            tagPre.setTextColor(Color.BLACK);
            //            String contentRSpecial = StringUtil.rmvSpecial(content);
            tagPre.setText(StringUtil.rmvSpecial(content));
            tagPre.setTextSize(TEXT_SIZE);
            tagPre.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    openDialog(tagPre.getText().toString());
                    return false;
                }
            });
            lineLayout.addView(tagPre);
        } else if (tag.equalsIgnoreCase("dt") || tag.equalsIgnoreCase("H1") || tag.equalsIgnoreCase("H2")
                || tag.equalsIgnoreCase("H3")) {//title
            TextView tagDtHTV = new TextView(mContext);
            tagDtHTV.setBackgroundColor(Color.DKGRAY);
            tagDtHTV.setTypeface(null, Typeface.BOLD);
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.WRAP_CONTENT);
            lp.setMargins(2, 0, 2, 0);
            tagDtHTV.setLayoutParams(lp);
            tagDtHTV.setPadding(2, 2, 2, 2);
            tagDtHTV.setPaddingRelative(2, 2, 2, 2);
            tagDtHTV.setMovementMethod(ScrollingMovementMethod.getInstance());
            tagDtHTV.setTextColor(Color.WHITE);
            tagDtHTV.setText(contentRSpecial);
            tagDtHTV.setTextSize(TEXT_SIZE);
            lineLayout.addView(tagDtHTV);
        } else if (tag.equalsIgnoreCase("dd")) {
            final TextView tagDD = new TextView(mContext);
            tagDD.setBackgroundResource(R.drawable.tag_p_drawable);
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.WRAP_CONTENT);
            lp.setMargins(2, 2, 2, 2);
            tagDD.setLayoutParams(lp);
            tagDD.setPadding(3, 3, 3, 3);
            tagDD.setPaddingRelative(3, 3, 3, 3);
            tagDD.setMovementMethod(ScrollingMovementMethod.getInstance());
            tagDD.setTextColor(Color.BLACK);
            tagDD.setText(contentRSpecial);
            tagDD.setTextSize(TEXT_SIZE);
            tagDD.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    openDialog(tagDD.getText().toString());
                    return false;
                }
            });
            lineLayout.addView(tagDD);
        } else if (tag.equalsIgnoreCase("li")) {
            final TextView tagLigTV = new TextView(mContext);
            tagLigTV.setBackgroundResource(R.drawable.tag_p_drawable);
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.WRAP_CONTENT);
            lp.setMargins(2, 2, 2, 2);
            tagLigTV.setLayoutParams(lp);
            tagLigTV.setPaddingRelative(2, 2, 2, 2);
            tagLigTV.setMovementMethod(ScrollingMovementMethod.getInstance());
            tagLigTV.setTextColor(Color.BLACK);
            tagLigTV.setText(contentRSpecial);
            tagLigTV.setTextSize(TEXT_SIZE);
            tagLigTV.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    openDialog(tagLigTV.getText().toString());
                    return false;
                }
            });
            lineLayout.addView(tagLigTV);
        } else if (tag.equalsIgnoreCase("img")) {
            final TextView imgTV = new TextView(mContext);
            imgTV.setBackgroundResource(R.drawable.tag_p_drawable);
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.WRAP_CONTENT);
            lp.setMargins(2, 2, 2, 2);
            imgTV.setLayoutParams(lp);
            imgTV.setPaddingRelative(2, 2, 2, 2);
            imgTV.setMovementMethod(ScrollingMovementMethod.getInstance());
            imgTV.setTextColor(Color.BLACK);
            imgTV.setText(content);
            imgTV.setTextSize(TEXT_SIZE);
            lineLayout.addView(imgTV);

            ImageView imageView = new ImageView(mContext);
            LinearLayout.LayoutParams imgLP = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                    LayoutParams.WRAP_CONTENT);
            imageView.setLayoutParams(imgLP);
            Bitmap localBt = getLoacalBitmap(baseFolder + File.separator + content);
            imageView.setImageBitmap(localBt);
            lineLayout.addView(imageView);
        }
    }
}

From source file:metrocasas.projectsgt.MainActivity.java

private void initializeImageSwitcher() {
    final ImageSwitcher imageSwitcher = (ImageSwitcher) findViewById(R.id.imgSwitcher);
    assert imageSwitcher != null;
    imageSwitcher.setFactory(new ViewSwitcher.ViewFactory() {
        @Override/* w w  w.  jav a2 s.  co  m*/
        public View makeView() {
            return new ImageView(MainActivity.this);
        }
    });
    //imageSwitcher.setInAnimation(AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left));
    //imageSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this, android.R.anim.slide_out_right));
}

From source file:org.chromium.chrome.browser.payments.ui.PaymentRequestSection.java

private ImageView createAndAddChevron(ViewGroup parent) {
    Resources resources = parent.getResources();
    TintedDrawable chevron = TintedDrawable.constructTintedDrawable(resources, R.drawable.ic_expanded,
            R.color.payments_section_chevron);

    ImageView view = new ImageView(parent.getContext());
    view.setImageDrawable(chevron);//w w  w.j av a 2  s. c o m

    // Wrap whatever image is passed in.
    LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    ApiCompatibilityUtils.setMarginStart(params, mLargeSpacing);
    parent.addView(view, params);
    return view;
}

From source file:com.sft.blackcatapp.EnrollSchoolActivity.java

private void setViewPager() {
    InfinitePagerAdapter adapter = null;
    int length = 0;
    if (adImageUrl != null && adImageUrl.length > 0) {
        adapter = new InfinitePagerAdapter(this, adImageUrl, screenWidth, viewPagerHeight);
        length = adImageUrl.length;/*from   ww w .j  a  va2s .c  o  m*/
    } else {
        adapter = new InfinitePagerAdapter(this, new int[] { R.drawable.defaultimage });
        length = 1;
        defaultImage.setVisibility(View.GONE);
    }
    adapter.setPageClickListener(new MyPageClickListener());
    adapter.setURLErrorListener(this);
    topViewPager.setAdapter(adapter);

    imageViews = new ImageView[length];
    ImageView imageView = null;
    dotLayout.removeAllViews();
    LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams((int) (8 * screenDensity),
            (int) (4 * screenDensity));
    dotLayout.addView(new TextView(this), textParams);
    // ?
    for (int i = 0; i < length; i++) {
        imageView = new ImageView(this);
        // ?imageview?
        imageView.setLayoutParams(new LayoutParams((int) (6 * screenDensity), (int) (6 * screenDensity)));// ?20
        // 
        // ?layout
        imageView.setBackgroundResource(R.drawable.enroll_school_dot_selector);
        imageViews[i] = imageView;

        // ???
        if (i == 0) {
            imageView.setEnabled(true);
        } else {
            imageView.setEnabled(false);
        }
        // imageviews?
        dotLayout.addView(imageViews[i]);
        dotLayout.addView(new TextView(this), textParams);
    }
}

From source file:cl.gisred.android.PowerOnActivity.java

private void abrirLeyenda() {
    ImageView image = new ImageView(this);
    image.setImageResource(R.drawable.leyenda_power);
    image.setAdjustViewBounds(true);//from   w w  w .  j  a va  2s. co m

    AlertDialog.Builder builder = new AlertDialog.Builder(this)
            .setPositiveButton("CERRAR", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).setView(image);

    builder.create().show();
}

From source file:no.ntnu.idi.socialhitchhiking.map.MapActivityCreateOrEditRoute.java

/** initAddDestButton()
 * adds the Driving Through button/*ww  w .j a v a  2  s .  c o  m*/
 */
protected void initAddDestButton() {

    //Adds/enables the FrameLayout
    AddDestFrameLayout = new FrameLayout(this);
    AddDestFrameLayout.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT, 80));
    AddDestFrameLayout.setEnabled(true);

    //Fills the Image Icon
    ImageView destAddIcon = new ImageView(this);
    FrameLayout.LayoutParams lliDestIcon = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);
    lliDestIcon.setMargins(dipToPx(10), 0, 0, dipToPx(2));
    destAddIcon.setLayoutParams(lliDestIcon);
    destAddIcon.setPadding(0, dipToPx(5), 0, 0);
    destAddIcon.setImageResource(R.drawable.google_marker_thumb_mini_through);

    //Adds the imageicon to the framelayout/enables it 
    AddDestFrameLayout.addView(destAddIcon);

    //Fills/sets the text
    TextView destAddText = new TextView(this);
    FrameLayout.LayoutParams lliDest = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);
    lliDest.setMargins(0, dipToPx(5), 0, 0);
    destAddText.setLayoutParams(lliDest);
    destAddText.setPadding(dipToPx(40), dipToPx(6), 0, 0);
    destAddText.setTextSize(15);
    destAddText.setText(R.string.mapViewAcField);

    //Adds the text to the framelayout
    AddDestFrameLayout.addView(destAddText);

    //Adds the framelayout to the linearlayout (in the scrollview)
    sclLayout = (LinearLayout) findViewById(R.id.sclLayout);
    sclLayout.addView(AddDestFrameLayout, sclLayout.getChildCount());

    final Button button = ((Button) findViewById(R.id.btnChooseRoute));

    //Adds a clicklistener to the frameLayout
    AddDestFrameLayout.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            //Adds a new destination field
            initDestFrameLayout();

            //Moves the button to the bottom
            setLayoutParams();

            if (checkFields() == false) {
                button.setEnabled(false);
                button.setText("Show on map");
            } else {
                mapView.getOverlays().clear();
                createMap();
            }
        }

    });
}

From source file:com.acc.android.util.widget.adapter.ImageAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    // if (false) {
    // if (this.accFileCallback == null) {
    // return null;
    // }/*from  w w  w  . j  a v a2 s.c  o m*/
    ACCFile accFile = this.imageData.getAccFiles().get(position);
    ImageView imageView = !this.isBig ? new ImageView(this.context)
            : new AutoImageView(this.context, position == 0, position == this.getCount() - 1,
                    this.onSingleTapListener);
    Bitmap bitmap = this.bitmapProviderManager.getBitmap(accFile);
    // if (bitmap == null || bitmap.isRecycled()) {
    // bitmap = BitmapManager.getInstance(context).getBlankBitmap();
    // }
    // LogUtil.systemOut("bitmap == null:");
    // LogUtil.systemOut(bitmap == null);
    // if (true) {
    if (this.isBig) {
        imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
    }
    // this.isBig ?
    // :autoImageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
    imageView.setLayoutParams(new Gallery.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    // imageView.setBackgroundResource(R.drawable.login_input);
    // }
    // System.out.println(position);
    imageView.setImageBitmap(bitmap);
    if (this.isBig && accFile.getProgress() != null) {
        ((AutoImageView) imageView).setProgress(accFile.getProgress());
    }
    // }
    return imageView;
}

From source file:fr.tvbarthel.attempt.googlyzooapp.MainActivity.java

/**
 * build captured preview layout// w  w  w  . ja va2s  .com
 */
private void setUpCapturePreview() {
    mCapturePreview = new ImageView(this);
    mCapturePreview.setScaleType(ImageView.ScaleType.CENTER_CROP);
    mCapturePreviewParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    mCapturePreviewParams.gravity = Gravity.CENTER;
    mCapturePreview.setVisibility(View.GONE);
    mPreviewRequested = false;
}

From source file:org.catrobat.catroid.ui.fragment.AddBrickFragment.java

public ImageView getGlowingBorder(Bitmap bitmap) {
    ImageView imageView = new ImageView(getActivity());
    imageView.setBackgroundColor(Color.TRANSPARENT);
    imageView.setId(R.id.drag_and_drop_list_view_image_view);

    Bitmap glowingBitmap = Bitmap.createBitmap(bitmap.getWidth() + 30, bitmap.getHeight() + 30,
            Bitmap.Config.ARGB_8888);/*from ww  w. ja v a2 s. c  o m*/
    Canvas glowingCanvas = new Canvas(glowingBitmap);
    Bitmap alpha = bitmap.extractAlpha();
    Paint paintBlur = new Paint();
    paintBlur.setColor(Color.WHITE);
    glowingCanvas.drawBitmap(alpha, 15, 15, paintBlur);
    BlurMaskFilter blurMaskFilter = new BlurMaskFilter(15.0f, BlurMaskFilter.Blur.OUTER);
    paintBlur.setMaskFilter(blurMaskFilter);
    glowingCanvas.drawBitmap(alpha, 15, 15, paintBlur);
    paintBlur.setMaskFilter(null);
    glowingCanvas.drawBitmap(bitmap, 15, 15, paintBlur);

    imageView.setImageBitmap(glowingBitmap);

    return imageView;
}

From source file:ca.ualberta.cs.swapmyride.View.AddInventoryActivity.java

/**
 * After returning from the camera activity, get the photo information
 * and send it into the structure to get it ready.
 *//*w w w . j a v a2 s  .co m*/

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
        Bundle extras = data.getExtras();
        Bitmap imageBitmap = (Bitmap) extras.get("data");
        Photo photo = new Photo(imageBitmap);
        ImageView newImage = new ImageView(getApplicationContext());
        newImage.setImageBitmap(photo.getImage());
        newImage.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
        newImage.setAdjustViewBounds(true);
        //gallery.removeAllViews();
        gallery.addView(newImage);
        photos.add(photo);
    }

}