本文整理汇总了Java中android.content.Context.getDrawable方法的典型用法代码示例。如果您正苦于以下问题:Java Context.getDrawable方法的具体用法?Java Context.getDrawable怎么用?Java Context.getDrawable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.Context
的用法示例。
在下文中一共展示了Context.getDrawable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateStatus
import android.content.Context; //导入方法依赖的package包/类
private void updateStatus(FFMStatus status) {
if (status.getGroupBlacklist() != null) {
FFMSettings.putLocalGroupWhitelistValue(status.getGroupBlacklist().isEnabled() ? status.getGroupBlacklist().getCount() : -1);
}
if (status.getDiscussWhitelist() != null) {
FFMSettings.putLocalDiscussWhitelistValue(status.getDiscussWhitelist().isEnabled() ? status.getDiscussWhitelist().getCount() : -1);
}
if (status.isRunning()) {
updateStatus(status.getDevices());
} else {
Context context = getContext();
int color = context.getColor(R.color.serverProblem);
Drawable icon = context.getDrawable(R.drawable.ic_status_error_24dp);
updateStatus(context.getString(R.string.status_webqq_dead), color, icon);
}
}
示例2: getPreloadProgressPath
import android.content.Context; //导入方法依赖的package包/类
private Path getPreloadProgressPath(Context context) {
if (AndroidVersion.isAtLeastOreo()) {
try {
// Try to load the path from Mask Icon
Drawable icon = context.getDrawable(R.drawable.adaptive_icon_drawable_wrapper);
icon.setBounds(0, 0,
PreloadIconDrawable.PATH_SIZE, PreloadIconDrawable.PATH_SIZE);
return (Path) icon.getClass().getMethod("getIconMask").invoke(icon);
} catch (Exception e) {
e.printStackTrace();
}
}
// Create a circle static from top center and going clockwise.
Path p = new Path();
p.moveTo(PreloadIconDrawable.PATH_SIZE / 2, 0);
p.addArc(0, 0, PreloadIconDrawable.PATH_SIZE, PreloadIconDrawable.PATH_SIZE, -90, 360);
return p;
}
示例3: ResolverDrawerLayout
import android.content.Context; //导入方法依赖的package包/类
public ResolverDrawerLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ResolverDrawerLayout,
defStyleAttr, 0);
mMaxWidth = a.getDimensionPixelSize(R.styleable.ResolverDrawerLayout_android_maxWidth, -1);
mMaxCollapsedHeight = a.getDimensionPixelSize(
R.styleable.ResolverDrawerLayout_maxCollapsedHeight, 0);
mMaxCollapsedHeightSmall = a.getDimensionPixelSize(
R.styleable.ResolverDrawerLayout_maxCollapsedHeightSmall,
mMaxCollapsedHeight);
a.recycle();
mScrollIndicatorDrawable = context.getDrawable(R.drawable.scroll_indicator_material);
mScroller = new OverScroller(context, AnimationUtils.loadInterpolator(context,
android.R.interpolator.decelerate_quint));
mVelocityTracker = VelocityTracker.obtain();
final ViewConfiguration vc = ViewConfiguration.get(context);
mTouchSlop = vc.getScaledTouchSlop();
mMinFlingVelocity = vc.getScaledMinimumFlingVelocity();
setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
}
示例4: create
import android.content.Context; //导入方法依赖的package包/类
public static PopupWindow create(@NonNull Context context, @NonNull BubbleLayout bubbleLayout) {
PopupWindow popupWindow = new PopupWindow(context);
popupWindow.setContentView(bubbleLayout);
popupWindow.setOutsideTouchable(true);
popupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
popupWindow.setAnimationStyle(android.R.style.Animation_Dialog);
// change background color to transparent
Drawable drawable;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
drawable = context.getDrawable(R.drawable.popup_window_transparent);
} else {
drawable = context.getResources().getDrawable(R.drawable.popup_window_transparent);
}
popupWindow.setBackgroundDrawable(drawable);
return popupWindow;
}
示例5: IconConfig
import android.content.Context; //导入方法依赖的package包/类
public IconConfig(@NonNull Context context, TypedArray typedArray) {
DEFAULT_SIZE = IconDotTextView.sDefaultIconSize;
if (typedArray != null) {
width = typedArray.getDimensionPixelSize(R.styleable.IconDotTextView_icon_width, DEFAULT_SIZE);
height = typedArray.getDimensionPixelSize(R.styleable.IconDotTextView_icon_height, DEFAULT_SIZE);
if (!hasSpecifyWidthAndHeight()) {
size = typedArray.getDimensionPixelSize(R.styleable.IconDotTextView_icon_size, DEFAULT_SIZE);
}
int res = typedArray.getResourceId(R.styleable.IconDotTextView_icon, -1);
if (res != -1) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
icon = context.getDrawable(res);
} else {
icon = context.getResources().getDrawable(res);
}
}
}
}
示例6: getDrawableCompat
import android.content.Context; //导入方法依赖的package包/类
private Drawable getDrawableCompat(Context context, int id) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return context.getDrawable(id);
} else {
return context.getResources().getDrawable(id);
}
}
示例7: getDrawable
import android.content.Context; //导入方法依赖的package包/类
public static Drawable getDrawable(Context context, int id){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return context.getDrawable(id);
} else {
return context.getResources().getDrawable(id);
}
}
示例8: getBitmap
import android.content.Context; //导入方法依赖的package包/类
private static Bitmap getBitmap(Context context,int vectorDrawableId) {
Bitmap bitmap=null;
if (Build.VERSION.SDK_INT>Build.VERSION_CODES.LOLLIPOP){
Drawable vectorDrawable = context.getDrawable(vectorDrawableId);
bitmap = Bitmap.createBitmap(vectorDrawable.getIntrinsicWidth(),
vectorDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
vectorDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
vectorDrawable.draw(canvas);
}else {
bitmap = BitmapFactory.decodeResource(context.getResources(), vectorDrawableId);
}
return bitmap;
}
示例9: getDrawable
import android.content.Context; //导入方法依赖的package包/类
private static Drawable getDrawable(Context context, int id) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
return context.getResources().getDrawable(id);
} else {
return context.getDrawable(id);
}
}
示例10: getDrawable
import android.content.Context; //导入方法依赖的package包/类
static Drawable getDrawable(@NonNull Context context, @DrawableRes int id) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
return context.getDrawable(id);
} else{
return context.getResources().getDrawable(id);
}
}
示例11: getDrawable
import android.content.Context; //导入方法依赖的package包/类
private Drawable getDrawable(Context context, int id) {
if (android.os.Build.VERSION.SDK_INT >= 21) {
return context.getDrawable(id);
} else {
return context.getResources().getDrawable(id);
}
}
示例12: getMaskDrawable
import android.content.Context; //导入方法依赖的package包/类
public static Drawable getMaskDrawable(Context context, int maskId) {
Drawable drawable;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
drawable = context.getDrawable(maskId);
} else {
drawable = context.getResources().getDrawable(maskId);
}
if (drawable == null) {
throw new IllegalArgumentException("maskId is invalid");
}
return drawable;
}
示例13: DividerItemDecoration
import android.content.Context; //导入方法依赖的package包/类
/**
* Creates a divider {@link RecyclerView.ItemDecoration} that can be used with a
* {@link LinearLayoutManager}.
*
* @param context Current context, it will be used to access resources.
* @param orientation Divider orientation. Should be {@link #HORIZONTAL} or {@link #VERTICAL}.
*/
public DividerItemDecoration(Context context, int orientation) {
// final TypedArray a = context.obtainStyledAttributes(ATTRS);
// mDivider = a.getDrawable(0);
// a.recycle();
// @By_syk
mDivider = context.getDrawable(R.drawable.app_list_divider);
setOrientation(orientation);
}
示例14: getDrawable
import android.content.Context; //导入方法依赖的package包/类
static Drawable getDrawable(Context context, int drawableResId) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return context.getDrawable(drawableResId);
} else {
try {
return VectorDrawableCompat.create(context.getResources(), drawableResId, null);
}catch (Resources.NotFoundException e){
return ContextCompat.getDrawable(context, drawableResId);
}
}
}
示例15: getDrawable
import android.content.Context; //导入方法依赖的package包/类
public static Drawable getDrawable(Context context, int id) {
return context.getDrawable(id);
}