本文整理匯總了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);
}