本文整理汇总了Java中android.support.v4.content.res.ResourcesCompat.getDrawable方法的典型用法代码示例。如果您正苦于以下问题:Java ResourcesCompat.getDrawable方法的具体用法?Java ResourcesCompat.getDrawable怎么用?Java ResourcesCompat.getDrawable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.content.res.ResourcesCompat
的用法示例。
在下文中一共展示了ResourcesCompat.getDrawable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setButtonColor
import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
private void setButtonColor() {
if (kanboardColors == null || defaultColor == null)
return;
btnColor.setEnabled(true);
Drawable dot = ResourcesCompat.getDrawable(getResources(), R.drawable.shape_circle, null);
if (colorId != null && kanboardColors.get(colorId) != null) { //FIXME: it seems that colorId can have a value that is not in the list. Fallback to defaultColor for now.
dot.setColorFilter(kanboardColors.get(colorId).getBackground(), PorterDuff.Mode.MULTIPLY);
btnColor.setText(Utils.fromHtml(getString(R.string.taskedit_color, kanboardColors.get(colorId).getName())));
} else {
dot.setColorFilter(kanboardColors.get(defaultColor).getBackground(), PorterDuff.Mode.MULTIPLY);
btnColor.setText(Utils.fromHtml(getString(R.string.taskedit_color, kanboardColors.get(defaultColor).getName())));
}
btnColor.setCompoundDrawablesRelativeWithIntrinsicBounds(dot, null, null, null);
}
示例2: setOpenWebsiteEnabled
import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
@Override public void setOpenWebsiteEnabled(boolean isEnabled) {
int id = isEnabled ? R.drawable.ic_open_in_browser : R.drawable.ic_open_in_browser_disabled;
int text = isEnabled ? R.color.color_icon : R.color.color_icon_disabled;
Drawable openInBrowserIcon = ResourcesCompat.getDrawable(getResources(), id, null);
btnOpenWebsite.setCompoundDrawablesWithIntrinsicBounds(null, openInBrowserIcon, null, null);
btnOpenWebsite.setTextColor(ContextCompat.getColor(this, text));
}
示例3: getListSelector
import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
protected final Drawable getListSelector() {
if (builder.listSelector != 0)
return ResourcesCompat.getDrawable(builder.context.getResources(), builder.listSelector, null);
final Drawable d = DialogUtils.resolveDrawable(builder.context, R.attr.md_list_selector);
if (d != null) return d;
return DialogUtils.resolveDrawable(getContext(), R.attr.md_list_selector);
}
示例4: enableEditPermissions
import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
@Override public void enableEditPermissions(boolean isEnabled) {
int id = isEnabled ? R.drawable.ic_edit : R.drawable.ic_edit_disabled;
int text = isEnabled ? R.color.color_icon : R.color.color_icon_disabled;
Drawable editIcon = ResourcesCompat.getDrawable(getResources(), id, null);
btnEditSettings.setCompoundDrawablesWithIntrinsicBounds(null, editIcon, null, null);
btnEditSettings.setTextColor(ContextCompat.getColor(this, text));
}
示例5: initStartButton
import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
private void initStartButton() {
final Drawable pinkArrow = ResourcesCompat.getDrawable(getResources(),
R.drawable.ic_navigate_next_accent, null);
if (pinkArrow != null) {
pinkArrow.setBounds(0, 0, 60, 60);
startButton.setCompoundDrawables(null, null, pinkArrow, null);
}
}
示例6: setThemeBackground
import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
private void setThemeBackground(View view) {
TypedValue a = new TypedValue();
getActivity().getTheme().resolveAttribute(android.R.attr.windowBackground, a, true);
if (a.type >= TypedValue.TYPE_FIRST_COLOR_INT && a.type <= TypedValue.TYPE_LAST_COLOR_INT) {
view.setBackgroundColor(a.data);
} else {
try {
Drawable d = ResourcesCompat.getDrawable(getActivity().getResources(), a.resourceId, getActivity().getTheme());
ViewCompat.setBackground(view, d);
} catch (Resources.NotFoundException ignore) {
}
}
}
示例7: bindMovie
import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
void bindMovie(Movie movie) {
mMovie = movie;
movieTitle.setText(movie.getTitle());
Drawable placeholder = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.background_reel, null);
Picasso.with(mContext)
.load(Constants.TMDB_IMAGE_URL + Constants.POSTER_SIZE_W342 + movie.getPosterPath())
.placeholder(placeholder)
.fit().centerCrop()
.noFade()
.into(moviePoster);
}
示例8: getDrawableFromLoaclSrc
import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
public static Drawable getDrawableFromLoaclSrc(Context context, Uri rewrited) {
Resources resources = context.getResources();
List<String> segments = rewrited.getPathSegments();
if (segments.size() != 1) {
WXLogUtils.e("Local src format is invalid.");
return null;
}
int id = resources.getIdentifier(segments.get(0), "drawable", context.getPackageName());
return id == 0 ? null : ResourcesCompat.getDrawable(resources, id, null);
}
示例9: bindMovie
import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
void bindMovie(PersonPopular person) {
this.person = person;
name.setText(person.getName());
Drawable placeholder =
ResourcesCompat.getDrawable(
mContext.getResources(), R.drawable.disk_reel, null);
Picasso.with(mContext)
.load(TMDB_IMAGE_URL + SIZE_W342 + person.getProfilePath())
.placeholder(placeholder)
.fit().centerCrop()
.noFade()
.into(personPoster);
}
示例10: bindTv
import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
void bindTv(TV tv) {
mTV = tv;
tvTitle.setText(tv.getName());
Drawable placeholder = ResourcesCompat.getDrawable(mContext.getResources(), R.drawable.background_reel, null);
Picasso.with(mContext)
.load(Constants.TMDB_IMAGE_URL + Constants.POSTER_SIZE_W342 + tv.getPosterPath())
.placeholder(placeholder)
.fit().centerCrop()
.noFade()
.into(tvPoster);
}
示例11: getDrawableByName
import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
public static Drawable getDrawableByName(Context context, String drawableName) {
Resources resources = context.getResources();
if (TextUtils.isEmpty(drawableName)) {
WXLogUtils.e("drawableName is null");
return null;
}
int id = resources.getIdentifier(drawableName, "drawable", context.getPackageName());
return id == 0 ? null : ResourcesCompat.getDrawable(resources, id, null);
}
示例12: setIcon
import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
@Override
public Builder setIcon(@DrawableRes Integer iconRes) {
this.iconDrawable = ResourcesCompat.getDrawable(context.getResources(), iconRes, null);
return this;
}
示例13: loadDrawableV4
import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
private static Drawable loadDrawableV4(
Context context, @DrawableRes int id, @Nullable Theme theme) {
Resources resources = context.getResources();
return ResourcesCompat.getDrawable(resources, id, theme);
}
示例14: init
import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
private void init(AttributeSet attrs) {
isSliding = false;
if (attrs != null) {
TypedArray ta = getContext().obtainStyledAttributes(attrs, R.styleable.ImageRatingBar, 0, 0);
try {
smileWidth = ta.getDimensionPixelSize(R.styleable.ImageRatingBar_smileWidth, 0);
smileHeight = ta.getDimensionPixelSize(R.styleable.ImageRatingBar_smileHeight, 0);
horizontalSpacing = ta.getDimensionPixelSize(R.styleable.ImageRatingBar_horizontalSpacing, 0);
isEnabled = ta.getBoolean(R.styleable.ImageRatingBar_enabled, true);
rating = ta.getInt(R.styleable.ImageRatingBar_rating, NO_RATING);
defaultSmile = new Drawable[] {
ResourcesCompat.getDrawable(getResources(), R.drawable.rating_gray_1, null),
ResourcesCompat.getDrawable(getResources(), R.drawable.rating_gray_2, null),
ResourcesCompat.getDrawable(getResources(), R.drawable.rating_gray_3, null),
ResourcesCompat.getDrawable(getResources(), R.drawable.rating_gray_4, null),
ResourcesCompat.getDrawable(getResources(), R.drawable.rating_gray_5, null),
ResourcesCompat.getDrawable(getResources(), R.drawable.rating_gray_6, null),
ResourcesCompat.getDrawable(getResources(), R.drawable.rating_gray_7, null),
ResourcesCompat.getDrawable(getResources(), R.drawable.rating_gray_8, null),
ResourcesCompat.getDrawable(getResources(), R.drawable.rating_gray_9, null)
};
ratingSmiles = new Drawable[] {
ResourcesCompat.getDrawable(getResources(), R.drawable.rating_1, null),
ResourcesCompat.getDrawable(getResources(), R.drawable.rating_2, null),
ResourcesCompat.getDrawable(getResources(), R.drawable.rating_3, null),
ResourcesCompat.getDrawable(getResources(), R.drawable.rating_4, null),
ResourcesCompat.getDrawable(getResources(), R.drawable.rating_5, null),
ResourcesCompat.getDrawable(getResources(), R.drawable.rating_6, null),
ResourcesCompat.getDrawable(getResources(), R.drawable.rating_7, null),
ResourcesCompat.getDrawable(getResources(), R.drawable.rating_8, null),
ResourcesCompat.getDrawable(getResources(), R.drawable.rating_9, null)
};
if (smileWidth == 0)
smileWidth = 50;
if (smileHeight == 0)
smileHeight = 50;
} finally {
ta.recycle();
}
}
points = new PointF[MAX_RATE];
for (int i = 0; i < MAX_RATE; i++) {
points[i] = new PointF();
}
if (rating != NO_RATING)
setRating(rating);
}
示例15: setUpMapIfNeeded
import android.support.v4.content.res.ResourcesCompat; //导入方法依赖的package包/类
/**
* Description: Initialises the Map and sets initial options such as:
* Zoom levels and controls
* Compass
* ScaleBar
* Cluster Pin colors
* Location update settings
*/
private void setUpMapIfNeeded() {
// Check if we were successful in obtaining the map.
mMap.setBuiltInZoomControls(true);
mMap.setMultiTouchControls(true);
mMap.setMinZoomLevel(3);
mMap.setMaxZoomLevel(19); // Latest OSM can go to 21!
mMap.getTileProvider().createTileCache();
mCompassOverlay = new CompassOverlay(getActivity(), new InternalCompassOrientationProvider(getActivity()), mMap);
ScaleBarOverlay mScaleBarOverlay = new ScaleBarOverlay(getActivity());
mScaleBarOverlay.setScaleBarOffset(getResources().getDisplayMetrics().widthPixels / 2, 10);
mScaleBarOverlay.setCentred(true);
// Sets cluster pin color
mCellTowerGridMarkerClusterer = new CellTowerGridMarkerClusterer(getActivity());
//BitmapDrawable mapPinDrawable = (BitmapDrawable) getResources().getDrawable(R.drawable.ic_map_pin_orange);
BitmapDrawable mapPinDrawable = (BitmapDrawable) ResourcesCompat.getDrawable(getResources(), R.drawable.ic_map_pin_orange, null);
mCellTowerGridMarkerClusterer.setIcon(mapPinDrawable == null ? null : mapPinDrawable.getBitmap());
GpsMyLocationProvider gpsMyLocationProvider = new GpsMyLocationProvider(getActivity().getBaseContext());
gpsMyLocationProvider.setLocationUpdateMinDistance(100); // [m] // Set the minimum distance for location updates
gpsMyLocationProvider.setLocationUpdateMinTime(10000); // [ms] // Set the minimum time interval for location updates
mMyLocationOverlay = new MyLocationNewOverlay(getActivity().getBaseContext(), gpsMyLocationProvider, mMap);
mMyLocationOverlay.setDrawAccuracyEnabled(true);
mMap.getOverlays().add(mCellTowerGridMarkerClusterer);
mMap.getOverlays().add(mMyLocationOverlay);
mMap.getOverlays().add(mCompassOverlay);
mMap.getOverlays().add(mScaleBarOverlay);
}