當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。