本文整理汇总了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);
}
示例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();
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例14: setImageResource
import android.support.annotation.DrawableRes; //导入依赖的package包/类
@Override
public void setImageResource(@DrawableRes int resId) {
super.setImageResource(resId);
if (mImageHelper != null) {
mImageHelper.setImageResource(resId);
}
}
示例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);
}
}