Java Code Examples for android.widget.ImageView.setLayerType()

The following are Jave code examples for showing how to use setLayerType() of the android.widget.ImageView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: GitHub   File: ImageLoader.java   View Source Code Vote up 8 votes
private void setSuccessDrawable4Callback(final Drawable drawable) {
    final ImageView view = viewRef.get();
    if (view != null) {
        view.setScaleType(options.getImageScaleType());
        if (drawable instanceof GifDrawable) {
            if (view.getScaleType() == ImageView.ScaleType.CENTER) {
                view.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
            }
            view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        }
        if (options.getAnimation() != null) {
            ImageAnimationHelper.animationDisplay(view, drawable, options.getAnimation());
        } else if (options.isFadeIn()) {
            ImageAnimationHelper.fadeInDisplay(view, drawable);
        } else {
            view.setImageDrawable(drawable);
        }
    }
}
 
Example 2
Project: GitHub   File: SvgSoftwareLayerSetter.java   View Source Code Vote up 6 votes
@Override
public boolean onLoadFailed(GlideException e, Object model, Target<PictureDrawable> target,
    boolean isFirstResource) {
  ImageView view = ((ImageViewTarget<?>) target).getView();
  view.setLayerType(ImageView.LAYER_TYPE_NONE, null);
  return false;
}
 
Example 3
Project: GitHub   File: SvgSoftwareLayerSetter.java   View Source Code Vote up 6 votes
@Override
public boolean onResourceReady(PictureDrawable resource, Object model,
    Target<PictureDrawable> target, DataSource dataSource, boolean isFirstResource) {
  ImageView view = ((ImageViewTarget<?>) target).getView();
  view.setLayerType(ImageView.LAYER_TYPE_SOFTWARE, null);
  return false;
}
 
Example 4
Project: GitHub   File: SvgSoftwareLayerSetter.java   View Source Code Vote up 6 votes
@Override
public boolean onLoadFailed(GlideException e, Object model, Target<PictureDrawable> target,
    boolean isFirstResource) {
  ImageView view = ((ImageViewTarget<?>) target).getView();
  view.setLayerType(ImageView.LAYER_TYPE_NONE, null);
  return false;
}
 
Example 5
Project: GitHub   File: SvgSoftwareLayerSetter.java   View Source Code Vote up 6 votes
@Override
public boolean onResourceReady(PictureDrawable resource, Object model,
    Target<PictureDrawable> target, DataSource dataSource, boolean isFirstResource) {
  ImageView view = ((ImageViewTarget<?>) target).getView();
  view.setLayerType(ImageView.LAYER_TYPE_SOFTWARE, null);
  return false;
}
 
Example 6
Project: TripleTap   File: SetGameCardView.java   View Source Code Vote up 6 votes
/**
 * Adds the appropriate symbol to the center of the card. This takes the
 * class attributes and displays the image with the correct shape, color, and fill
 * and can be called multiple times to display the correct count of symbols.
 *
 * @param context Context of our view
 */
private void addImage(Context context, LinearLayout linearLayout) {

    ImageView symbolView = new ImageView(context);

    /*
     * Turn off hardware acceleration for this View otherwise
     * the colors don't get drawn correctly
     */
    symbolView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);


    // Set the height of the image to 1/2 the card height
    int imageHeight = (int) Math.floor(getHeight() * 0.7);
    int imageWidth = imageHeight / 2;
    LayoutParams params = new LayoutParams(
            imageWidth,
            imageHeight
    );
    params.setMarginEnd(10);
    params.setMarginStart(10);
    symbolView.setLayoutParams(params);

    // Get drawable resource from ShapeFill array
    Drawable symbol = context.getDrawable(mShapeFill[mShape][mFill]);

    // Set symbol color based on defaults or user preferences
    setSymbolColor(symbol);

    // Set the drawable to the imageview
    symbolView.setImageDrawable(symbol);

    // Add the completed imageview to the layout
    linearLayout.addView(symbolView, 0);
}