當前位置: 首頁>>代碼示例>>Java>>正文


Java DrawableRes類代碼示例

本文整理匯總了Java中android.support.annotation.DrawableRes的典型用法代碼示例。如果您正苦於以下問題:Java DrawableRes類的具體用法?Java DrawableRes怎麽用?Java DrawableRes使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DrawableRes類屬於android.support.annotation包,在下文中一共展示了DrawableRes類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setCryptoMessageSingleLine

import android.support.annotation.DrawableRes; //導入依賴的package包/類
private void setCryptoMessageSingleLine(@AttrRes int colorAttr,
        @StringRes int topTextRes, @DrawableRes int statusIconRes,
        @DrawableRes Integer statusDotsRes) {
    @ColorInt int color = ThemeUtils.getStyledColor(getActivity(), colorAttr);

    authenticationIcon_1.setImageResource(statusIconRes);
    authenticationIcon_1.setColorFilter(color);
    authenticationText.setText(topTextRes);

    if (statusDotsRes != null) {
        authenticationIcon_3.setImageResource(statusDotsRes);
        authenticationIcon_3.setColorFilter(color);
        authenticationIcon_3.setVisibility(View.VISIBLE);
    } else {
        authenticationIcon_3.setVisibility(View.GONE);
    }

    trustText.setVisibility(View.GONE);
    trustIconFrame.setVisibility(View.GONE);
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:21,代碼來源:SecurityInfoDialog.java

示例2: setCryptoMessageWithAnimation

import android.support.annotation.DrawableRes; //導入依賴的package包/類
private void setCryptoMessageWithAnimation(@AttrRes int colorAttr,
        @StringRes int topTextRes, @DrawableRes int statusIconRes,
        @StringRes int bottomTextRes, @DrawableRes int statusDotsRes) {
    authenticationIcon_1.setImageResource(statusIconRes);
    authenticationIcon_2.setImageResource(statusDotsRes);
    authenticationIcon_3.setVisibility(View.GONE);
    authenticationText.setText(topTextRes);

    trustIcon_1.setImageResource(statusIconRes);
    trustIcon_2.setImageResource(statusDotsRes);
    trustText.setText(bottomTextRes);

    authenticationIcon_1.setColorFilter(ThemeUtils.getStyledColor(getActivity(), colorAttr));
    trustIcon_2.setColorFilter(ThemeUtils.getStyledColor(getActivity(), colorAttr));

    prepareIconAnimation();
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:18,代碼來源:SecurityInfoDialog.java

示例3: addView

import android.support.annotation.DrawableRes; //導入依賴的package包/類
/**
 * Function to add view to component
 *
 * @param tag              View tag usually the step number
 * @param drawableResource drawable resource of view
 */
private void addView(int tag, @DrawableRes int drawableResource, boolean isLastStep) {
    // inflate view to component
    View view = LayoutInflater.from(getContext()).inflate(R.layout.step_view_item, rootView, false);

    //set view size and margins
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(stepSize, stepSize);
    layoutParams.setMargins(10, 10, 10, 10);
    view.findViewById(R.id.iv_main_step_image).setLayoutParams(layoutParams);
    view.setTag(tag);

    //set view background color
    setStepColorStatus(false, view);

    //add Image icon to view and add view
    ((ImageView) view.findViewById(R.id.iv_main_step_image)).setImageResource(drawableResource);
    rootView.addView(view);

    if (!isLastStep) {
        view = LayoutInflater.from(getContext()).inflate(R.layout.split_view_item, rootView, false);
        rootView.addView(view);
    }

}
 
開發者ID:mmoamenn,項目名稱:Steps_Android,代碼行數:30,代碼來源:CircleImageSteps.java

示例4: load

import android.support.annotation.DrawableRes; //導入依賴的package包/類
private void load(Context context, @DrawableRes int drawableRes, int textSize, String url) {
    if (!nativeLoad(handle, url)) {
        nativeClose(handle);
        throw new RuntimeException("not gif");
    } else {
        frameNum = nativeGetFrameCount(handle);
        for (int i = 0; i < frameNum; i++) {
            BitmapDrawable drawable = new BitmapDrawable(context.getResources(), nativeGetFrame(handle, i));
            int width = (textSize * drawable.getIntrinsicWidth()) / drawable.getIntrinsicHeight();
            drawable.setBounds(0, 0, width, textSize);
            EmoticonCache.saveDrawable(drawableRes, i, drawable);
            delay = nativeGetDelay(handle, i);
        }
        nativeClose(handle);
    }
}
 
開發者ID:hoanganhtuan95ptit,項目名稱:GifEmoji,代碼行數:17,代碼來源:EmoticonDecoder.java

示例5: getTintedDrawable

import android.support.annotation.DrawableRes; //導入依賴的package包/類
@UiThread // Implicit synchronization for use of shared resource VALUE.
public static Drawable getTintedDrawable(Context context,
    @DrawableRes int id, @AttrRes int tintAttrId) {
  boolean attributeFound = context.getTheme().resolveAttribute(tintAttrId, VALUE, true);
  if (!attributeFound) {
    throw new Resources.NotFoundException("Required tint color attribute with name "
        + context.getResources().getResourceEntryName(tintAttrId)
        + " and attribute ID "
        + tintAttrId
        + " was not found.");
  }

  Drawable drawable = ContextCompat.getDrawable(context, id);
  drawable = DrawableCompat.wrap(drawable.mutate());
  int color = ContextCompat.getColor(context, VALUE.resourceId);
  DrawableCompat.setTint(drawable, color);
  return drawable;
}
 
開發者ID:qq542391099,項目名稱:butterknife-parent,代碼行數:19,代碼來源:Utils.java

示例6: drawTextToDrawable

import android.support.annotation.DrawableRes; //導入依賴的package包/類
public Bitmap drawTextToDrawable(@DrawableRes int resId, String text, int textSize) {
    Resources resources = _context.getResources();
    float scale = resources.getDisplayMetrics().density;
    Bitmap bitmap = getBitmapFromDrawable(resId);

    bitmap = bitmap.copy(bitmap.getConfig(), true);
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setColor(Color.rgb(61, 61, 61));
    paint.setTextSize((int) (textSize * scale));
    paint.setShadowLayer(1f, 0f, 1f, Color.WHITE);

    Rect bounds = new Rect();
    paint.getTextBounds(text, 0, text.length(), bounds);
    int x = (bitmap.getWidth() - bounds.width()) / 2;
    int y = (bitmap.getHeight() + bounds.height()) / 2;
    canvas.drawText(text, x, y, paint);

    return bitmap;
}
 
開發者ID:gsantner,項目名稱:memetastic,代碼行數:21,代碼來源:ContextUtils.java

示例7: addIndicator

import android.support.annotation.DrawableRes; //導入依賴的package包/類
private void addIndicator(int orientation, @DrawableRes int backgroundDrawableId,
        Animator animator) {
    if (animator.isRunning()) {
        animator.end();
        animator.cancel();
    }

    View Indicator = new View(getContext());
    Indicator.setBackgroundResource(backgroundDrawableId);
    addView(Indicator, mIndicatorWidth, mIndicatorHeight);
    LayoutParams lp = (LayoutParams) Indicator.getLayoutParams();

    if (orientation == HORIZONTAL) {
        lp.leftMargin = mIndicatorMargin;
        lp.rightMargin = mIndicatorMargin;
    } else {
        lp.topMargin = mIndicatorMargin;
        lp.bottomMargin = mIndicatorMargin;
    }

    Indicator.setLayoutParams(lp);

    animator.setTarget(Indicator);
    animator.start();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:26,代碼來源:CircleIndicator.java

示例8: setStatusDrawableRes

import android.support.annotation.DrawableRes; //導入依賴的package包/類
@Override
public boolean setStatusDrawableRes(@DrawableRes int drawableRes) {
    Activity activity = mActivityRef.get();
    if (activity != null) {
        Drawable drawable = ContextCompat.getDrawable(activity, drawableRes);
        setStatusDrawable(drawable);
    }
    return true;
}
 
開發者ID:ls1110924,項目名稱:ImmerseMode,代碼行數:10,代碼來源:TpSbTlNbwFCImmerseMode.java

示例9: setCompoundDrawablesRelativeWithIntrinsicBounds

import android.support.annotation.DrawableRes; //導入依賴的package包/類
@Override
public void setCompoundDrawablesRelativeWithIntrinsicBounds(
        @DrawableRes int start, @DrawableRes int top, @DrawableRes int end, @DrawableRes int bottom) {
    super.setCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom);
    if (mTextHelper != null) {
        mTextHelper.onSetCompoundDrawablesRelativeWithIntrinsicBounds(start, top, end, bottom);
    }
}
 
開發者ID:ximsfei,項目名稱:Android-skin-support,代碼行數:9,代碼來源:SkinCompatRadioButton.java

示例10: getTintedDrawable

import android.support.annotation.DrawableRes; //導入依賴的package包/類
public static Drawable getTintedDrawable(Context ctx, @DrawableRes int drawableResId,
                                         @ColorRes int colorResId) {
    Resources res = ctx.getResources();
    Drawable drawable = ContextCompat.getDrawable(ctx, drawableResId);
    int color = res.getColor(colorResId);
    drawable.setColorFilter(color, PorterDuff.Mode.SRC_IN);
    return drawable;
}
 
開發者ID:Datatellit,項目名稱:xlight_android_native,代碼行數:9,代碼來源:Ui.java

示例11: setImageResource

import android.support.annotation.DrawableRes; //導入依賴的package包/類
@Override
public void setImageResource(@DrawableRes int resId) {
    // Intercept this call and instead retrieve the Drawable via the image helper
    if (mImageHelper != null) {
        mImageHelper.setImageResource(resId);
    }
}
 
開發者ID:ximsfei,項目名稱:Android-skin-support,代碼行數:8,代碼來源:SkinCompatImageView.java

示例12: updateBackground

import android.support.annotation.DrawableRes; //導入依賴的package包/類
/**
 * Procedure sets the background for given view as a drawable with given resource id
 */
@SuppressWarnings("deprecation")
public static void updateBackground(Context c, View v, @DrawableRes int drawableId)
{
    Drawable bg = null;

    if (drawableId >= 0)
    {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        {
            bg = c.getResources().getDrawable(drawableId, c.getTheme());
        }
        else
        {
            bg = c.getResources().getDrawable(drawableId);
        }
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
    {
        v.setBackground(bg);
    }
    else
    {
        v.setBackgroundDrawable(bg);
    }
}
 
開發者ID:mkulesh,項目名稱:microMathematics,代碼行數:30,代碼來源:CompatUtils.java

示例13: setImageUri

import android.support.annotation.DrawableRes; //導入依賴的package包/類
/**
 * 淡入淡出加載圖片
 *
 * @param imageview        圖片控件
 * @param uri              圖片uri
 * @param errorResId       加載失敗時顯示的圖片資源id
 * @param placeholderResId 加載時的占位圖資源id
 */
public void setImageUri(@NonNull ImageView imageview, Uri uri, @DrawableRes int errorResId, @DrawableRes int placeholderResId) {
    Glide.with(mContext)
            .load(uri)
            .crossFade()
            .error(errorResId)
            .placeholder(placeholderResId)
            .into(imageview);
}
 
開發者ID:codeccc,項目名稱:baselibrary-master,代碼行數:17,代碼來源:BaseFragment.java

示例14: setImageResource

import android.support.annotation.DrawableRes; //導入依賴的package包/類
@Override
public void setImageResource(@DrawableRes int resId) {
    super.setImageResource(resId);
    if (mImageHelper != null) {
        mImageHelper.setImageResource(resId);
    }
}
 
開發者ID:ximsfei,項目名稱:Android-skin-support,代碼行數:8,代碼來源:SkinCompatCircleImageView.java

示例15: setImageResource

import android.support.annotation.DrawableRes; //導入依賴的package包/類
@Override
public void setImageResource(@DrawableRes int resId) {
    if (animation != null) {
        throw new IllegalStateException("Changing the LoadingDots image resource is not supported");
    } else {
        super.setImageResource(resId);
    }
}
 
開發者ID:Comcast,項目名稱:loadingdots,代碼行數:9,代碼來源:LoadingDots.java


注:本文中的android.support.annotation.DrawableRes類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。