Search in sources :

Example 86 with ImageView

use of android.widget.ImageView in project SmartTabLayout by ogaclejapan.

the class DemoTabWithNotificationMarkActivity method createTabView.

@Override
public View createTabView(ViewGroup container, int position, PagerAdapter adapter) {
    LayoutInflater inflater = LayoutInflater.from(container.getContext());
    Resources res = container.getContext().getResources();
    View tab = inflater.inflate(R.layout.custom_tab_icon_and_notification_mark, container, false);
    View mark = tab.findViewById(R.id.custom_tab_notification_mark);
    mark.setVisibility(View.GONE);
    ImageView icon = (ImageView) tab.findViewById(R.id.custom_tab_icon);
    switch(position) {
        case 0:
            icon.setImageDrawable(res.getDrawable(R.drawable.ic_home_white_24dp));
            break;
        case 1:
            icon.setImageDrawable(res.getDrawable(R.drawable.ic_search_white_24dp));
            break;
        case 2:
            icon.setImageDrawable(res.getDrawable(R.drawable.ic_person_white_24dp));
            break;
        default:
            throw new IllegalStateException("Invalid position: " + position);
    }
    return tab;
}
Also used : LayoutInflater(android.view.LayoutInflater) Resources(android.content.res.Resources) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View)

Example 87 with ImageView

use of android.widget.ImageView in project Android-Universal-Image-Loader by nostra13.

the class OldRoundedBitmapDisplayer method roundCorners.

/**
	 * Process incoming {@linkplain Bitmap} to make rounded corners according to target
	 * {@link com.nostra13.universalimageloader.core.imageaware.ImageViewAware}.<br />
	 * This method <b>doesn't display</b> result bitmap in {@link ImageView}
	 *
	 * @param bitmap      Incoming Bitmap to process
	 * @param imageAware  Target {@link com.nostra13.universalimageloader.core.imageaware.ImageAware ImageAware} to
	 *                    display bitmap in
	 * @param roundPixels Rounded pixels of corner
	 * @return Result bitmap with rounded corners
	 */
public static Bitmap roundCorners(Bitmap bitmap, ImageViewAware imageAware, int roundPixels) {
    ImageView imageView = imageAware.getWrappedView();
    if (imageView == null) {
        L.w("View is collected probably. Can't round bitmap corners without view properties.");
        return bitmap;
    }
    Bitmap roundBitmap;
    int bw = bitmap.getWidth();
    int bh = bitmap.getHeight();
    int vw = imageAware.getWidth();
    int vh = imageAware.getHeight();
    if (vw <= 0)
        vw = bw;
    if (vh <= 0)
        vh = bh;
    final ImageView.ScaleType scaleType = imageView.getScaleType();
    if (scaleType == null) {
        return bitmap;
    }
    int width, height;
    Rect srcRect;
    Rect destRect;
    switch(scaleType) {
        case CENTER_INSIDE:
            float vRation = (float) vw / vh;
            float bRation = (float) bw / bh;
            int destWidth;
            int destHeight;
            if (vRation > bRation) {
                destHeight = Math.min(vh, bh);
                destWidth = (int) (bw / ((float) bh / destHeight));
            } else {
                destWidth = Math.min(vw, bw);
                destHeight = (int) (bh / ((float) bw / destWidth));
            }
            int x = (vw - destWidth) / 2;
            int y = (vh - destHeight) / 2;
            srcRect = new Rect(0, 0, bw, bh);
            destRect = new Rect(x, y, x + destWidth, y + destHeight);
            width = vw;
            height = vh;
            break;
        case FIT_CENTER:
        case FIT_START:
        case FIT_END:
        default:
            vRation = (float) vw / vh;
            bRation = (float) bw / bh;
            if (vRation > bRation) {
                width = (int) (bw / ((float) bh / vh));
                height = vh;
            } else {
                width = vw;
                height = (int) (bh / ((float) bw / vw));
            }
            srcRect = new Rect(0, 0, bw, bh);
            destRect = new Rect(0, 0, width, height);
            break;
        case CENTER_CROP:
            vRation = (float) vw / vh;
            bRation = (float) bw / bh;
            int srcWidth;
            int srcHeight;
            if (vRation > bRation) {
                srcWidth = bw;
                srcHeight = (int) (vh * ((float) bw / vw));
                x = 0;
                y = (bh - srcHeight) / 2;
            } else {
                srcWidth = (int) (vw * ((float) bh / vh));
                srcHeight = bh;
                x = (bw - srcWidth) / 2;
                y = 0;
            }
            // Math.min(vw, bw);
            width = srcWidth;
            //Math.min(vh, bh);
            height = srcHeight;
            srcRect = new Rect(x, y, x + srcWidth, y + srcHeight);
            destRect = new Rect(0, 0, width, height);
            break;
        case FIT_XY:
            width = vw;
            height = vh;
            srcRect = new Rect(0, 0, bw, bh);
            destRect = new Rect(0, 0, width, height);
            break;
        case CENTER:
        case MATRIX:
            width = Math.min(vw, bw);
            height = Math.min(vh, bh);
            x = (bw - width) / 2;
            y = (bh - height) / 2;
            srcRect = new Rect(x, y, x + width, y + height);
            destRect = new Rect(0, 0, width, height);
            break;
    }
    try {
        roundBitmap = getRoundedCornerBitmap(bitmap, roundPixels, srcRect, destRect, width, height);
    } catch (OutOfMemoryError e) {
        L.e(e, "Can't create bitmap with rounded corners. Not enough memory.");
        roundBitmap = bitmap;
    }
    return roundBitmap;
}
Also used : Bitmap(android.graphics.Bitmap) Rect(android.graphics.Rect) ImageView(android.widget.ImageView) Paint(android.graphics.Paint)

Example 88 with ImageView

use of android.widget.ImageView in project android-demos by novoda.

the class OptionsDisplay method configureOption.

private View configureOption(View option, CharSequence title, boolean active) {
    ImageView iconView = getOptionIcon(option);
    iconView.setEnabled(active);
    getOptionTitle(option).setText(title);
    return option;
}
Also used : ImageView(android.widget.ImageView)

Example 89 with ImageView

use of android.widget.ImageView in project weiciyuan by qii.

the class LocalWorker method onCancelled.

@Override
protected void onCancelled(Bitmap bitmap) {
    super.onCancelled(bitmap);
    ImageView imageView = viewWeakReference.get();
    if (!isMySelf(imageView)) {
        return;
    }
    imageView.setImageDrawable(new ColorDrawable(DebugColor.READ_CANCEL));
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) ImageView(android.widget.ImageView)

Example 90 with ImageView

use of android.widget.ImageView in project weiciyuan by qii.

the class ReadWorker method onProgressUpdate.

@Override
protected void onProgressUpdate(Integer... values) {
    super.onProgressUpdate(values);
    if (TimeLineBitmapDownloader.pauseDownloadWork) {
        return;
    }
    ImageView imageView = viewWeakReference.get();
    if (!isMySelf(imageView)) {
        return;
    }
    if (pbWeakReference != null) {
        ProgressBar pb = pbWeakReference.get();
        if (pb != null) {
            Integer progress = values[0];
            Integer max = values[1];
            pb.setMax(max);
            pb.setProgress(progress);
        }
    }
}
Also used : ImageView(android.widget.ImageView) ProgressBar(android.widget.ProgressBar)

Aggregations

ImageView (android.widget.ImageView)2257 View (android.view.View)1144 TextView (android.widget.TextView)1005 Intent (android.content.Intent)200 Drawable (android.graphics.drawable.Drawable)197 LinearLayout (android.widget.LinearLayout)192 Bitmap (android.graphics.Bitmap)178 ViewGroup (android.view.ViewGroup)163 LayoutInflater (android.view.LayoutInflater)159 OnClickListener (android.view.View.OnClickListener)145 AdapterView (android.widget.AdapterView)111 ListView (android.widget.ListView)103 RecyclerView (android.support.v7.widget.RecyclerView)102 FrameLayout (android.widget.FrameLayout)97 Button (android.widget.Button)83 Bundle (android.os.Bundle)81 BitmapDrawable (android.graphics.drawable.BitmapDrawable)80 RelativeLayout (android.widget.RelativeLayout)72 Test (org.junit.Test)70 Context (android.content.Context)69