android.widget.ImageView#getBackground ( )源码实例Demo

下面列出了android.widget.ImageView#getBackground ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: PowerFileExplorer   文件: ColorPref.java
@NonNull
@Override
public View getView(final int position, View convertView, @NonNull ViewGroup parent) {
    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    //TODO solve unconditional layout inflation
    View rowView = inflater.inflate(R.layout.dialog_grid_item, parent, false);

    int color = getColor(getColorResAt(position));

    ImageView imageView = (ImageView) rowView.findViewById(R.id.icon);
    if (color == selectedColor)
        imageView.setImageResource(R.drawable.ic_checkmark_selected);
    GradientDrawable gradientDrawable = (GradientDrawable) imageView.getBackground();

    gradientDrawable.setColor(color);

    return rowView;
}
 
源代码2 项目: MyHearts   文件: MainActivityDrawerLayout.java
/**
 * 自己去调整
 */
private void initAnimation() {
    // 获取ImageView上的动画背景
    AnimationDrawable spinnerLive = (AnimationDrawable) mIvLive.getBackground();

    // 开始动画
    spinnerLive.start();

    mIvImg = (ImageView) findViewById(R.id.img_img);

    // 获取ImageView上的动画背景
    AnimationDrawable spinnerImg = (AnimationDrawable) mIvImg.getBackground();
    // 开始动画
    spinnerImg.start();

}
 
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	Log.setDefaultLevel(Log.SUPPRESS);
	
	// If there is no intent scheduled, set a repeating alarm for library updates.
	setupRepeatingLibraryUpdateAlarm();
	
	setContentView(R.layout.activity_home);
	
	// According to http://stackoverflow.com/a/2791816/931277, setting dither="true" on the shape tag in xml doesn't work.
	// However, using the debugger on the Nexus 7 (4.2), when it's set in xml it is in fact set on this Drawable, so this
	// *should* be unnecessary. It won't hurt, though.
	ImageView splash = (ImageView) findViewById(R.id.activity_home_imageview);
	Drawable background = splash.getBackground();
	if (background instanceof GradientDrawable) {
		((GradientDrawable) background).setDither(true);
	}
}
 
源代码4 项目: FoodOrdering   文件: CommProgressDialog.java
public void onWindowFocusChanged(boolean hasFocus){

        if (commProgressDialog == null){
            return;
        }

        ImageView imageView = (ImageView) commProgressDialog.findViewById(R.id.iv_loading);
        if(anim!=0) {
            imageView.setBackgroundResource(anim);
        }
        AnimationDrawable animationDrawable = (AnimationDrawable) imageView.getBackground();
        animationDrawable.start();
    }
 
源代码5 项目: Ticket-Analysis   文件: XinxinRefreshLayout.java
public RefreshHeader(Context context) {
    super(context);
    View header = LayoutInflater.from(context).inflate(R.layout.header_refresh_common, this);
    imageMoneyDown = (ImageView) header.findViewById(R.id.imageDown);

    animationDrawable = (AnimationDrawable) imageMoneyDown.getBackground();
    animationDrawable.stop();
}
 
源代码6 项目: GravityBox   文件: ModNavigationBar.java
private static void setKeyColorRecursive(ViewGroup vg) {
    if (vg == null) return;
    final int childCount = vg.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = vg.getChildAt(i);
        if (child instanceof ViewGroup) {
            setKeyColorRecursive((ViewGroup) child);
        } else if (child instanceof ImageView) {
            ImageView imgv = (ImageView) vg.getChildAt(i);
            if (mNavbarColorsEnabled) {
                imgv.setColorFilter(mKeyColor, PorterDuff.Mode.SRC_ATOP);
            } else {
                imgv.clearColorFilter();
            }
            if (imgv.getClass().getName().equals(CLASS_KEY_BUTTON_VIEW) &&
                    !mNavbarColorsEnabled) {
                Drawable ripple = imgv.getBackground();
                if (ripple != null &&
                        ripple.getClass().getName().equals(CLASS_KEY_BUTTON_RIPPLE)) {
                    Paint paint = (Paint) XposedHelpers.getObjectField(ripple, "mRipplePaint");
                    if (paint != null) {
                        paint.setColor(0xffffffff);
                    }
                }
            } else if (imgv instanceof KeyButtonView) {
                ((KeyButtonView) imgv).setGlowColor(mNavbarColorsEnabled ?
                        mKeyGlowColor : mKeyDefaultGlowColor);
            }
        }
    }
}
 
源代码7 项目: MyHearts   文件: CustomPrograss.java
/**
 * 当窗口焦点改变时调用
 */
public void onWindowFocusChanged(boolean hasFocus) {
    ImageView imageView = (ImageView) findViewById(R.id.spinnerImageView);
    // 获取ImageView上的动画背景
    AnimationDrawable spinner = (AnimationDrawable) imageView.getBackground();
    // 开始动画
    spinner.start();
}
 
源代码8 项目: MaterialPreference   文件: ColorAdapter.java
@Override
public View getView(final int position, View convertView, ViewGroup parent) {


    LayoutInflater inflater = (LayoutInflater) getContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    View rowView = inflater.inflate(R.layout.dialog_grid_item, parent, false);

    ImageView imageView = (ImageView) rowView.findViewById(R.id.icon);

    if(secondary_position == position){
        imageView.setImageResource(R.drawable.mpref_done);
    }

    GradientDrawable gradientDrawable = (GradientDrawable) imageView.getBackground();
    gradientDrawable.setColor(Color.parseColor(getItem(position)));

    rowView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            MaterialPrefUtil.updateColor(position);
            notifyDataSetChanged();
            mCallback.onColorChanged(position);
        }
    });
    return rowView;
}
 
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    //holder.itemView.setClickable(false); // disable parent click
    ImageView imageView = (ImageView) holder.findViewById(R.id.imageViewIcon);
    //noinspection StatementWithEmptyBody
    if (imageView != null) {
        GradientDrawable gradientDrawable = (GradientDrawable) imageView.getBackground();
        gradientDrawable.setColor(Color.parseColor(MaterialPrefUtil.secondaryColor[MaterialPrefUtil.getSecondaryColorPosition()]));

        imageView.setClickable(true); // enable custom view click

    } else {
    }
}
 
源代码10 项目: Android-Basics-Codes   文件: MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);
	
	ImageView rocketImage = (ImageView) findViewById(R.id.iv);
	//��֡��������Դ�ļ���Ϊimageview�ı���ͼƬ
	rocketImage.setBackgroundResource(R.drawable.frameanimation);
	//��ȡimageView�ı������ѱ���ǿת�ɶ���Drawable
	AnimationDrawable rocketAnimation = (AnimationDrawable) rocketImage.getBackground();
	//���Ŷ���
	rocketAnimation.start();
}
 
源代码11 项目: Android-Basics-Codes   文件: MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);
	ImageView rocketImage = (ImageView) findViewById(R.id.rocket_image);
	rocketImage.setBackgroundResource(R.drawable.anim);
	rocketAnimation = (AnimationDrawable) rocketImage.getBackground();
}
 
源代码12 项目: SuntimesWidget   文件: SuntimesUtils.java
/**
 * @param view the ImageView
 * @param color color to apply
 */
public static void colorizeImageView(ImageView view, int color)
{
    if (view != null && view.getBackground() != null)
    {
        try {
            GradientDrawable d = (GradientDrawable) view.getBackground().mutate();
            d.setColor(color);
            d.invalidateSelf();

        } catch (ClassCastException e) {
            Log.w("colorizeImageView", "failed to colorize! " + e);
        }
    }
}
 
源代码13 项目: miappstore   文件: MoreHolder.java
@Override
public View initView() {
    View view = View.inflate(context, R.layout.item_load_more, null);
    load_empty = view.findViewById(R.id.load_empty);
    load_error = view.findViewById(R.id.load_error);
    load_more = view.findViewById(R.id.load_more);
    iv_loadmore = (ImageView) view.findViewById(R.id.iv_loadmore);
    background = (AnimationDrawable) iv_loadmore.getBackground();
    background.start();
    return view;
}
 
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.main);

	ImageView imageView = findViewById(R.id.countdown_frame);

	imageView.setBackgroundResource(R.drawable.view_animation);

	mAnim = (AnimationDrawable) imageView.getBackground();
}
 
源代码15 项目: letv   文件: SharedElementCallback.java
public Parcelable onCaptureSharedElementSnapshot(View sharedElement, Matrix viewToGlobalMatrix, RectF screenBounds) {
    Bitmap bitmap;
    if (sharedElement instanceof ImageView) {
        ImageView imageView = (ImageView) sharedElement;
        Drawable d = imageView.getDrawable();
        Drawable bg = imageView.getBackground();
        if (d != null && bg == null) {
            bitmap = createDrawableBitmap(d);
            if (bitmap != null) {
                Bundle bundle = new Bundle();
                bundle.putParcelable(BUNDLE_SNAPSHOT_BITMAP, bitmap);
                bundle.putString(BUNDLE_SNAPSHOT_IMAGE_SCALETYPE, imageView.getScaleType().toString());
                if (imageView.getScaleType() != ScaleType.MATRIX) {
                    return bundle;
                }
                float[] values = new float[9];
                imageView.getImageMatrix().getValues(values);
                bundle.putFloatArray(BUNDLE_SNAPSHOT_IMAGE_MATRIX, values);
                return bundle;
            }
        }
    }
    int bitmapWidth = Math.round(screenBounds.width());
    int bitmapHeight = Math.round(screenBounds.height());
    bitmap = null;
    if (bitmapWidth > 0 && bitmapHeight > 0) {
        float scale = Math.min(1.0f, ((float) MAX_IMAGE_SIZE) / ((float) (bitmapWidth * bitmapHeight)));
        bitmapWidth = (int) (((float) bitmapWidth) * scale);
        bitmapHeight = (int) (((float) bitmapHeight) * scale);
        if (this.mTempMatrix == null) {
            this.mTempMatrix = new Matrix();
        }
        this.mTempMatrix.set(viewToGlobalMatrix);
        this.mTempMatrix.postTranslate(-screenBounds.left, -screenBounds.top);
        this.mTempMatrix.postScale(scale, scale);
        bitmap = Bitmap.createBitmap(bitmapWidth, bitmapHeight, Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        canvas.concat(this.mTempMatrix);
        sharedElement.draw(canvas);
    }
    return bitmap;
}
 
源代码16 项目: zulip-android   文件: PhotoEditActivity.java
/**
 * This function is called when any of the marker colors are chosen.
 * Its sets the color for marker tool and changes its the background.
 *
 * @param view color ImageView
 */
public void handleMarkerColorChange(View view) {
    int colorId = R.color.red_marker_tool;
    switch (view.getId()) {
        case R.id.red_marker:
            colorId = R.color.red_marker_tool;
            break;
        case R.id.yellow_marker:
            colorId = R.color.yellow_marker_tool;
            break;
        case R.id.green_marker:
            colorId = R.color.green_marker_tool;
            break;
        case R.id.white_marker:
            colorId = R.color.white_marker_tool;
            break;
        case R.id.blue_marker:
            colorId = R.color.blue_marker_tool;
            break;
        case R.id.black_marker:
            colorId = R.color.black_marker_tool;
            break;
        default:
            Log.e("Marker Tool", "Invalid color");
            break;
    }

    // change marker tool color
    mDrawCustomView.setBrushColor(ContextCompat.getColor(this, colorId));

    // change background of marker tool
    ImageView markerIcon = (ImageView) findViewById(R.id.marker_btn);
    GradientDrawable markerBackground = (GradientDrawable) markerIcon.getBackground();
    markerBackground.setColor(ContextCompat.getColor(this, colorId));
    // if black color is selected, add a border to the background of marker tool
    if (colorId == R.color.black_marker_tool) {
        markerBackground.setStroke(3, Color.GRAY);
    } else {
        markerBackground.setStroke(0, Color.GRAY);
    }
}
 
源代码17 项目: twitter-kit-android   文件: TestUtils.java
public static int getBackgroundColor(ImageView imageView) {
    final ColorDrawable drawable = (ColorDrawable) imageView.getBackground();
    return drawable.getColor();
}
 
@Override
protected Drawable getViewDrawable(ImageView view) {
    // The states we need exist on the ImageView background (not on the
    // getDrawable(), like in a 'regular' image view).
    return view.getBackground();
}
 
源代码19 项目: reader   文件: AndroidProgressHUD.java
public void onWindowFocusChanged(boolean hasFocus){
ImageView imageView = (ImageView) findViewById(context.getResources().getIdentifier("spinnerImageView", "id", context.getPackageName()));
       AnimationDrawable spinner = (AnimationDrawable) imageView.getBackground();
       spinner.start();
   }
 
源代码20 项目: reader   文件: AndroidProgressHUD.java
public void onWindowFocusChanged(boolean hasFocus){
ImageView imageView = (ImageView) findViewById(context.getResources().getIdentifier("spinnerImageView", "id", context.getPackageName()));
       AnimationDrawable spinner = (AnimationDrawable) imageView.getBackground();
       spinner.start();
   }