当前位置: 首页>>代码示例>>Java>>正文


Java ResourcesCompat.getDrawable方法代码示例

本文整理汇总了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);
}
 
开发者ID:andresth,项目名称:Kandroid,代码行数:17,代码来源:TaskEditActivity.java

示例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));
}
 
开发者ID:philipphager,项目名称:disclosure-android-app,代码行数:9,代码来源:LibraryDetailActivity.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:MaterialDialog.java

示例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));
}
 
开发者ID:philipphager,项目名称:disclosure-android-app,代码行数:9,代码来源:AppDetailActivity.java

示例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);
    }
}
 
开发者ID:adithya321,项目名称:SOS-The-Healthcare-Companion,代码行数:9,代码来源:HelloActivity.java

示例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) {
        }
    }
}
 
开发者ID:franmontiel,项目名称:FullScreenDialog,代码行数:14,代码来源:FullScreenDialogFragment.java

示例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);
}
 
开发者ID:qqq3,项目名称:inventum,代码行数:12,代码来源:HomeMovieAdapter.java

示例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);
}
 
开发者ID:erguotou520,项目名称:weex-uikit,代码行数:11,代码来源:ImgURIUtil.java

示例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);
}
 
开发者ID:an-garcia,项目名称:MovieGuide,代码行数:14,代码来源:HomePersonAdapter.java

示例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);
}
 
开发者ID:qqq3,项目名称:inventum,代码行数:12,代码来源:HomeTvAdapter.java

示例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);
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:10,代码来源:ImageLoadUtil.java

示例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;
}
 
开发者ID:sega4revenge,项目名称:Sega,代码行数:6,代码来源:MaterialStyledDialog.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:DrawableDecoderCompat.java

示例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);
}
 
开发者ID:PacktPublishing,项目名称:Expert-Android-Programming,代码行数:53,代码来源:ImageRatingBar.java

示例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);
}
 
开发者ID:5GSD,项目名称:AIMSICDL,代码行数:40,代码来源:MapFragment.java


注:本文中的android.support.v4.content.res.ResourcesCompat.getDrawable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。