Java Code Examples for android.support.v7.widget.AppCompatImageView#setImageDrawable()
The following examples show how to use
android.support.v7.widget.AppCompatImageView#setImageDrawable() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseActivity.java From africastalking-android with MIT License | 6 votes |
protected void showInfo(String header, String desc, @Nullable Drawable drawable, boolean error) { hideKeyboard(); AppCompatTextView infoHeader = (AppCompatTextView) llBottomSheet.findViewById(R.id.info_header); AppCompatTextView infoDesc = (AppCompatTextView) llBottomSheet.findViewById(R.id.info_desc); AppCompatImageView infoImg = (AppCompatImageView) llBottomSheet.findViewById(R.id.info_img); if (error) { llBottomSheet.findViewById(R.id.info_img).setVisibility(View.GONE); ((AppCompatButton) findViewById(R.id.ok_dimiss)).setText("Close"); } else { llBottomSheet.findViewById(R.id.info_img).setVisibility(View.VISIBLE); ((AppCompatButton) findViewById(R.id.ok_dimiss)).setText("Ok"); } infoHeader.setText(header); infoDesc.setText(desc); if (drawable != null) infoImg.setImageDrawable(drawable); bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED); }
Example 2
Source File: Luhn.java From Luhn with MIT License | 6 votes |
private void showInfo(String header, String desc, @Nullable Drawable drawable, boolean error) { hideKeyboard(); AppCompatTextView infoHeader = (AppCompatTextView) llBottomSheet.findViewById(R.id.info_header); AppCompatTextView infoDesc = (AppCompatTextView) llBottomSheet.findViewById(R.id.info_desc); AppCompatImageView infoImg = (AppCompatImageView) llBottomSheet.findViewById(R.id.info_img); if (error) { llBottomSheet.findViewById(R.id.info_img).setVisibility(View.GONE); ((AppCompatButton) findViewById(R.id.ok_dimiss)).setText("Close"); } else { llBottomSheet.findViewById(R.id.info_img).setVisibility(View.VISIBLE); ((AppCompatButton) findViewById(R.id.ok_dimiss)).setText("Ok"); } infoHeader.setText(header); infoDesc.setText(desc); if (drawable != null) infoImg.setImageDrawable(drawable); bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED); }
Example 3
Source File: RecyclerViewBanner.java From RecyclerViewBanner with Apache License 2.0 | 6 votes |
/** * 指示器整体由数据列表容量数量的AppCompatImageView均匀分布在一个横向的LinearLayout中构成 * 使用AppCompatImageView的好处是在Fragment中也使用Compat相关属性 */ private void createIndicators() { mLinearLayout.removeAllViews(); for (int i = 0; i < mData.size(); i++) { AppCompatImageView img = new AppCompatImageView(getContext()); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); lp.leftMargin = mSpace / 2; lp.rightMargin = mSpace / 2; if (mSize >= dp2px(4)) { // 设置了indicatorSize属性 lp.width = lp.height = mSize; } else { // 如果设置的resource.xml没有明确的宽高,默认最小2dp,否则太小看不清 img.setMinimumWidth(dp2px(2)); img.setMinimumHeight(dp2px(2)); } img.setImageDrawable(i == 0 ? mSelectedDrawable : mUnselectedDrawable); mLinearLayout.addView(img, lp); } }
Example 4
Source File: AnimatedPencil.java From AnimatedPencil with Apache License 2.0 | 5 votes |
private void init(Context context, AttributeSet attrs) { final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.AnimatedPencil); if (typedArray != null) { color = typedArray.getColor(R.styleable.AnimatedPencil_pencil_color, color); typedArray.recycle(); } imageView = new AppCompatImageView(getContext()); addView(imageView, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); drawable = AppCompatDrawableManager.get().getDrawable(getContext(), R.drawable.awsb_ic_edit_animated_24); drawable = DrawableCompat.wrap(drawable).mutate(); DrawableCompat.setTint(drawable, color); imageView.setImageDrawable(drawable); }
Example 5
Source File: Animate.java From lock-screen with MIT License | 4 votes |
@TargetApi(Build.VERSION_CODES.M) public static void animate(AppCompatImageView view, AnimatedVectorDrawable scanFingerprint) { view.setImageDrawable(scanFingerprint); scanFingerprint.start(); }
Example 6
Source File: SpotlightView.java From Spotlight with Apache License 2.0 | 4 votes |
/** * Add arc above/below the circular target overlay. */ private void addArcAnimation(final Activity activity) { AppCompatImageView mImageView = new AppCompatImageView(activity); mImageView.setImageResource(R.drawable.ic_spotlight_arc); LayoutParams params = new LayoutParams(2 * (circleShape.getRadius() + extraPaddingForArc), 2 * (circleShape.getRadius() + extraPaddingForArc)); if (targetView.getPoint().y > getHeight() / 2) {//bottom if (targetView.getPoint().x > getWidth() / 2) {//Right params.rightMargin = getWidth() - targetView.getPoint().x - circleShape.getRadius() - extraPaddingForArc; params.bottomMargin = getHeight() - targetView.getPoint().y - circleShape.getRadius() - extraPaddingForArc; params.gravity = Gravity.RIGHT | Gravity.BOTTOM; } else { params.leftMargin = targetView.getPoint().x - circleShape.getRadius() - extraPaddingForArc; params.bottomMargin = getHeight() - targetView.getPoint().y - circleShape.getRadius() - extraPaddingForArc; params.gravity = Gravity.LEFT | Gravity.BOTTOM; } } else {//up mImageView.setRotation(180); //Reverse the view if (targetView.getPoint().x > getWidth() / 2) {//Right params.rightMargin = getWidth() - targetView.getPoint().x - circleShape.getRadius() - extraPaddingForArc; params.bottomMargin = getHeight() - targetView.getPoint().y - circleShape.getRadius() - extraPaddingForArc; params.gravity = Gravity.RIGHT | Gravity.BOTTOM; } else { params.leftMargin = targetView.getPoint().x - circleShape.getRadius() - extraPaddingForArc; params.bottomMargin = getHeight() - targetView.getPoint().y - circleShape.getRadius() - extraPaddingForArc; params.gravity = Gravity.LEFT | Gravity.BOTTOM; } } mImageView.postInvalidate(); mImageView.setLayoutParams(params); addView(mImageView); PorterDuffColorFilter porterDuffColorFilter = new PorterDuffColorFilter(lineAndArcColor, PorterDuff.Mode.SRC_ATOP); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { AnimatedVectorDrawable avd = (AnimatedVectorDrawable) ContextCompat.getDrawable(activity, R.drawable.avd_spotlight_arc); avd.setColorFilter(porterDuffColorFilter); mImageView.setImageDrawable(avd); avd.start(); } else { AnimatedVectorDrawableCompat avdc = AnimatedVectorDrawableCompat.create(activity, R.drawable.avd_spotlight_arc); avdc.setColorFilter(porterDuffColorFilter); mImageView.setImageDrawable(avdc); avdc.start(); } new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { @Override public void run() { addPathAnimation(activity); } }, 400); }