当前位置: 首页>>代码示例>>Java>>正文


Java AppCompatImageView.setImageDrawable方法代码示例

本文整理汇总了Java中android.support.v7.widget.AppCompatImageView.setImageDrawable方法的典型用法代码示例。如果您正苦于以下问题:Java AppCompatImageView.setImageDrawable方法的具体用法?Java AppCompatImageView.setImageDrawable怎么用?Java AppCompatImageView.setImageDrawable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v7.widget.AppCompatImageView的用法示例。


在下文中一共展示了AppCompatImageView.setImageDrawable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showInfo

import android.support.v7.widget.AppCompatImageView; //导入方法依赖的package包/类
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);
}
 
开发者ID:aksalj,项目名称:africastalking-android,代码行数:20,代码来源:BaseActivity.java

示例2: getView

import android.support.v7.widget.AppCompatImageView; //导入方法依赖的package包/类
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
    final RuuviTag tag = getItem(position);

    if (convertView == null) {
        convertView = LayoutInflater.from(getContext()).inflate(R.layout.row_item_add, parent, false);
    }

    ((TextView)convertView.findViewById(R.id.address)).setText(tag.id);
    ((TextView)convertView.findViewById(R.id.rssi)).setText(String.format(getContext().getResources().getString(R.string.signal_reading), tag.rssi));

    AppCompatImageView signalIcon = convertView.findViewById(R.id.signalIcon);
    if (tag.rssi < -80) signalIcon.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.icon_connection_1));
    else if (tag.rssi < -50) signalIcon.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.icon_connection_2));
    else signalIcon.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.icon_connection_3));

    return convertView;
}
 
开发者ID:ruuvi,项目名称:com.ruuvi.station,代码行数:20,代码来源:AddTagAdapter.java

示例3: showInfo

import android.support.v7.widget.AppCompatImageView; //导入方法依赖的package包/类
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);
}
 
开发者ID:KingsMentor,项目名称:Luhn,代码行数:20,代码来源:Luhn.java

示例4: addIconNormal

import android.support.v7.widget.AppCompatImageView; //导入方法依赖的package包/类
private void addIconNormal() {
    View view = LayoutInflater.from(getContext()).inflate(R.layout.indicator_single_icon, holder, false);
    view.setLayoutParams(getItemParams());

    AppCompatImageView imageView = (AppCompatImageView) view.findViewById(R.id.ic_single);
    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) imageView.getLayoutParams();
    params.setMargins(indicatorAttr.eai_ic_margin, indicatorAttr.eai_ic_margin, indicatorAttr.eai_ic_margin, indicatorAttr.eai_ic_margin);
    imageView.setLayoutParams(params);
    if (iconNormalResId != 0)
        imageView.setImageResource(iconNormalResId);
    else
        imageView.setImageDrawable(indicatorAttr.eai_ic_src);
    imageView.invalidate();
    holder.addView(view);
    holder.invalidate();
}
 
开发者ID:ahmet12,项目名称:easlider,代码行数:17,代码来源:EAIndicator.java

示例5: createIndicators

import android.support.v7.widget.AppCompatImageView; //导入方法依赖的package包/类
/**
 * 指示器整体由数据列表容量数量的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);
    }
}
 
开发者ID:loonggg,项目名称:RecyclerViewBanner,代码行数:24,代码来源:RecyclerViewBanner.java

示例6: createItemView

import android.support.v7.widget.AppCompatImageView; //导入方法依赖的package包/类
public QMUIBottomSheetItemView createItemView(Drawable drawable, CharSequence text, Object tag, int subscriptRes) {
    LayoutInflater inflater = LayoutInflater.from(mContext);
    QMUIBottomSheetItemView itemView = (QMUIBottomSheetItemView) inflater.inflate(R.layout.qmui_bottom_sheet_grid_item, null, false);
    TextView titleTV = (TextView) itemView.findViewById(R.id.grid_item_title);
    if (mItemTextTypeFace != null) {
        titleTV.setTypeface(mItemTextTypeFace);
    }
    titleTV.setText(text);

    itemView.setTag(tag);
    itemView.setOnClickListener(this);
    AppCompatImageView imageView = (AppCompatImageView) itemView.findViewById(R.id.grid_item_image);
    imageView.setImageDrawable(drawable);

    if (subscriptRes != 0) {
        ViewStub stub = (ViewStub) itemView.findViewById(R.id.grid_item_subscript);
        View inflated = stub.inflate();
        ((ImageView) inflated).setImageResource(subscriptRes);
    }
    return itemView;
}
 
开发者ID:QMUI,项目名称:QMUI_Android,代码行数:22,代码来源:QMUIBottomSheet.java

示例7: init

import android.support.v7.widget.AppCompatImageView; //导入方法依赖的package包/类
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);
}
 
开发者ID:florent37,项目名称:AnimatedPencil,代码行数:14,代码来源:AnimatedPencil.java

示例8: addIconCurrent

import android.support.v7.widget.AppCompatImageView; //导入方法依赖的package包/类
private void addIconCurrent() {
    currentIconView = (RelativeLayout) LayoutInflater.from(getContext()).inflate(R.layout.indicator_single_icon, this, false);
    currentIconView.setLayoutParams(getItemParams());

    AppCompatImageView imageView = (AppCompatImageView) currentIconView.findViewById(R.id.ic_single);
    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) imageView.getLayoutParams();
    params.setMargins(indicatorAttr.eai_ic_current_margin, indicatorAttr.eai_ic_current_margin, indicatorAttr.eai_ic_current_margin, indicatorAttr.eai_ic_current_margin);

    imageView.setLayoutParams(params);
    if (iconSelectedResId != 0)
        imageView.setImageResource(iconSelectedResId);
    else
        imageView.setImageDrawable(indicatorAttr.eai_ic_current_src);
    imageView.invalidate();

    tempView = (RelativeLayout) LayoutInflater.from(getContext()).inflate(R.layout.indicator_single_icon, this, false);
    tempView.setLayoutParams(getItemParams());

    AppCompatImageView imageView2 = (AppCompatImageView) tempView.findViewById(R.id.ic_single);
    imageView2.setLayoutParams(params);
    if (iconSelectedResId != 0)
        imageView2.setImageResource(iconSelectedResId);
    else
        imageView2.setImageDrawable(indicatorAttr.eai_ic_current_src);
    imageView2.invalidate();

    addView(currentIconView);
    addView(tempView);

    invalidate();
}
 
开发者ID:ahmet12,项目名称:easlider,代码行数:32,代码来源:EAIndicator.java

示例9: onCreate

import android.support.v7.widget.AppCompatImageView; //导入方法依赖的package包/类
@SuppressLint("RestrictedApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fingerprint_isloated);
    final AppCompatImageView fingerprintIsolated = findViewById(R.id.fingerprint_animator);
    mFingerprintAnimator = new LoopAnimatedVectorDrawableCompat(AnimatedVectorDrawableCompat.create(this,
            R.drawable.enrollment_fingerprint_isolated_animation));

    fingerprintIsolated.setBackgroundDrawable(AppCompatResources.getDrawable(FingerprintIsloatedActivity.this
            , top.trumeet.snippet.aospanimation.library.R.drawable.fp_illustration_enrollment));
    fingerprintIsolated.setSupportBackgroundTintList(ColorStateList.valueOf(getResources().getColor(top.trumeet.snippet.aospanimation.library.R.color.fingerprint_indicator_background_resting)));

    CheckBox showBackground = findViewById(R.id.check_show_background);
    showBackground.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            if (b) {
                fingerprintIsolated.setBackgroundDrawable(AppCompatResources.getDrawable(FingerprintIsloatedActivity.this
                        , top.trumeet.snippet.aospanimation.library.R.drawable.fp_illustration_enrollment));
                fingerprintIsolated.setSupportBackgroundTintList(ColorStateList.valueOf(getResources().getColor(top.trumeet.snippet.aospanimation.library.R.color.fingerprint_indicator_background_resting)));
            } else {
                fingerprintIsolated.setBackgroundDrawable(null);
            }
        }
    });

    fingerprintIsolated.setImageDrawable(mFingerprintAnimator.getDrawable());
}
 
开发者ID:Trumeet,项目名称:Animations,代码行数:30,代码来源:FingerprintIsloatedActivity.java

示例10: createLoadMoreProgressView

import android.support.v7.widget.AppCompatImageView; //导入方法依赖的package包/类
private void createLoadMoreProgressView()
{
    mLoadMoreView = LayoutInflater.from(getContext()).inflate(R.layout.loadmore, this, false);
    image_view = (AppCompatImageView) mLoadMoreView.findViewById(R.id.image_view);
    mLoadMoreProgress = new MaterialProgressDrawable(getContext(), image_view);
    mLoadMoreProgress.setBackgroundColor(CIRCLE_BG_LIGHT);
    image_view.setImageDrawable(mLoadMoreProgress);
    mLoadMoreProgress.setAlpha(MAX_ALPHA);
    mLoadMoreProgress.start();
    addView(mLoadMoreView);
}
 
开发者ID:lynnchurch,项目名称:SwipeRefreshPlusLayout,代码行数:12,代码来源:SwipeRefreshPlusLayout.java

示例11: addToolbarItem

import android.support.v7.widget.AppCompatImageView; //导入方法依赖的package包/类
public ImageView addToolbarItem(int viewId, int resourceId,View.OnClickListener clickDelegate) {
    AppCompatImageView modAdd = new AppCompatImageView(toolbar.getContext());
    if (viewId>0) {
        modAdd.setId(viewId);
    }
    modAdd.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    modAdd.setImageDrawable(ViewUtils.circleIcon(modAdd.getContext(), resourceId));
    modAdd.setOnClickListener(clickDelegate);
    toolbarLayout.addView(modAdd,toolbarLayout.getChildCount()-1, params);
    return modAdd;
}
 
开发者ID:gandulf,项目名称:DsaTab,代码行数:12,代码来源:FABToolbarHelper.java

示例12: intiView

import android.support.v7.widget.AppCompatImageView; //导入方法依赖的package包/类
/**
 * Inti view.
 */
protected void intiView() {
    exoControlsBack = new AppCompatImageView(getContext());
    exoControlsBack.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    int ss = VideoPlayUtils.dip2px(getContext(), 7f);
    exoControlsBack.setId(R.id.exo_controls_back);
    exoControlsBack.setImageDrawable(ContextCompat.getDrawable(getContext(), icBackImage));
    exoControlsBack.setPadding(ss, ss, ss, ss);
    FrameLayout frameLayout = playerView.getContentFrameLayout();
    frameLayout.setBackgroundColor(ContextCompat.getColor(activity, android.R.color.black));
    exoPlayErrorLayout.setVisibility(GONE);
    playReplayLayout.setVisibility(GONE);
    playBtnHintLayout.setVisibility(GONE);
    exoLoadingLayout.setVisibility(GONE);
    dialogProLayout.setVisibility(GONE);
    exoAudioLayout.setVisibility(GONE);
    exoBrightnessLayout.setVisibility(GONE);
    exoPlayLockLayout.setVisibility(GONE);
    exoPlayLockLayout.setBackgroundColor(Color.TRANSPARENT);
    exoLoadingLayout.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.simple_exo_color_33));
    exoLoadingLayout.setClickable(true);
    frameLayout.addView(exoBrightnessLayout, frameLayout.getChildCount());
    frameLayout.addView(exoAudioLayout, frameLayout.getChildCount());
    frameLayout.addView(dialogProLayout, frameLayout.getChildCount());
    frameLayout.addView(exoPlayErrorLayout, frameLayout.getChildCount());
    frameLayout.addView(playReplayLayout, frameLayout.getChildCount());
    frameLayout.addView(playBtnHintLayout, frameLayout.getChildCount());
    frameLayout.addView(exoLoadingLayout, frameLayout.getChildCount());
    frameLayout.addView(exoPlayLockLayout, frameLayout.getChildCount());
    if (exoPlayPreviewLayout != null) {
        frameLayout.addView(exoPlayPreviewLayout, frameLayout.getChildCount());
    }
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(VideoPlayUtils.dip2px(getContext(), 35f), VideoPlayUtils.dip2px(getContext(), 35f));
    frameLayout.addView(exoControlsBack, frameLayout.getChildCount(), layoutParams);
    exoPlayWatermark = (ImageView) playerView.findViewById(R.id.exo_player_watermark);
    videoLoadingShowText = (TextView) playerView.findViewById(R.id.exo_loading_show_text);
    exoPlayerLockProgress = (ExoDefaultTimeBar) exoPlayLockLayout.findViewById(R.id.exo_player_lock_progress);
    lockCheckBox = (AppCompatCheckBox) exoPlayLockLayout.findViewById(R.id.exo_player_lock_btn_id);
    exoPreviewBottomImage = (ImageView) playerView.findViewById(R.id.exo_preview_image_bottom);
    if (playerView.findViewById(R.id.exo_preview_image) != null) {
        exoPreviewImage = (ImageView) playerView.findViewById(R.id.exo_preview_image);
        exoPreviewImage.setBackgroundResource(android.R.color.transparent);
    } else {
        exoPreviewImage = exoPreviewBottomImage;
    }
}
 
开发者ID:yangchaojiang,项目名称:yjPlay,代码行数:49,代码来源:BaseView.java

示例13: addArcAnimation

import android.support.v7.widget.AppCompatImageView; //导入方法依赖的package包/类
/**
 * 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);
}
 
开发者ID:HueToYou,项目名称:ChatExchange-old,代码行数:62,代码来源:SpotlightView.java

示例14: animate

import android.support.v7.widget.AppCompatImageView; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.M)
public static void animate(AppCompatImageView view, AnimatedVectorDrawable scanFingerprint) {
    view.setImageDrawable(scanFingerprint);
    scanFingerprint.start();
}
 
开发者ID:amirarcane,项目名称:lock-screen,代码行数:6,代码来源:Animate.java

示例15: invalidateMenu

import android.support.v7.widget.AppCompatImageView; //导入方法依赖的package包/类
private void invalidateMenu() {
    // Mimic CollapsingToolbarLayout's CollapsingTextHelper
    final WindowInsetsCompat mLastInsets = getLastInsets();
    final int insetTop = mLastInsets != null ? mLastInsets.getSystemWindowInsetTop() : 0;
    final int expandRange = mCollapsingToolbar.getHeight() - ViewCompat.getMinimumHeight(
            mCollapsingToolbar) - insetTop;
    final float expansionFraction = Math.abs(mLastVerticalOffset) / (float) expandRange;

    int tintColor;
    if (getExpandedTextColor() == getCollapsedTextColor())
        tintColor = getExpandedTextColor();
    else
        tintColor = ATEUtil.blendColors(getExpandedTextColor(), getCollapsedTextColor(), expansionFraction);
    if (tintColor == Color.TRANSPARENT)
        tintColor = getExpandedTextColor();

    mToolbar.setTitleTextColor(tintColor);

    // Tint navigation icon, if any
    if (mOriginalNavIcon == null)
        mOriginalNavIcon = mToolbar.getNavigationIcon();
    if (mOriginalNavIcon != null)
        mToolbar.setNavigationIcon(TintHelper.createTintedDrawable(mOriginalNavIcon, tintColor));

    // Tint action buttons
    tintMenu(mToolbar, mMenu, tintColor);

    // Tint overflow
    if (mOriginalOverflowIcon == null) {
        final ArrayList<View> overflows = new ArrayList<>();
        @SuppressLint("PrivateResource")
        final String overflowDescription = mContext.getString(R.string.abc_action_menu_overflow_description);
        mCollapsingToolbar.findViewsWithText(overflows, overflowDescription,
                View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
        if (!overflows.isEmpty()) {
            mOverflowView = (AppCompatImageView) overflows.get(0);
            mOriginalOverflowIcon = mOverflowView.getDrawable();
        }
    }
    if (mOverflowView != null)
        mOverflowView.setImageDrawable(TintHelper.createTintedDrawable(mOriginalOverflowIcon, tintColor));
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:43,代码来源:ToolbarProcessor.java


注:本文中的android.support.v7.widget.AppCompatImageView.setImageDrawable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。