當前位置: 首頁>>代碼示例>>Java>>正文


Java Drawable類代碼示例

本文整理匯總了Java中android.graphics.drawable.Drawable的典型用法代碼示例。如果您正苦於以下問題:Java Drawable類的具體用法?Java Drawable怎麽用?Java Drawable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Drawable類屬於android.graphics.drawable包,在下文中一共展示了Drawable類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setupStandardMenuItemViewHolder

import android.graphics.drawable.Drawable; //導入依賴的package包/類
private void setupStandardMenuItemViewHolder(StandardMenuItemViewHolder holder,
        View convertView, final MenuItem item) {
    // Set up the icon.
    Drawable icon = item.getIcon();
    holder.image.setImageDrawable(icon);
    holder.image.setVisibility(icon == null ? View.GONE : View.VISIBLE);
    holder.image.setChecked(item.isChecked());
    holder.text.setText(item.getTitle());
    holder.text.setContentDescription(item.getTitleCondensed());

    boolean isEnabled = item.isEnabled();
    // Set the text color (using a color state list).
    holder.text.setEnabled(isEnabled);
    // This will ensure that the item is not highlighted when selected.
    convertView.setEnabled(isEnabled);

    convertView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mAppMenu.onItemClick(item);
        }
    });
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:24,代碼來源:AppMenuAdapter.java

示例2: getFullResIcon

import android.graphics.drawable.Drawable; //導入依賴的package包/類
/**
 * 根據ActivityInfo繪製圖標
 * @param info
 * @return
 */
public Drawable getFullResIcon(ActivityInfo info) {
    Resources resources;
    try {
        resources = mPackageManager.getResourcesForApplication(
                info.applicationInfo);
    } catch (PackageManager.NameNotFoundException e) {
        resources = null;
    }
    if (resources != null) {
        int iconId = info.getIconResource();
        if (iconId != 0) {
            return getFullResIcon(resources, iconId);
        }
    }

    return getFullResDefaultActivityIcon();
}
 
開發者ID:TeamBrainStorm,項目名稱:SimpleUILauncher,代碼行數:23,代碼來源:IconCache.java

示例3: showDetails

import android.graphics.drawable.Drawable; //導入依賴的package包/類
/**
 * Hide list, show details and instruct the details view to show the selected book.
 */
@Override
public void showDetails(Book book, Drawable thumb) {
  final FragmentManager fragmentManager = getFragmentManager();
  FragmentTransaction ft = fragmentManager.beginTransaction();
  BookDetailsFragment details = (BookDetailsFragment) fragmentManager.findFragmentById(R.id.book_details);

  if (book != null) {
    // If null passed, we only configure fragment transaction here.
    details.showDetails(book, thumb);
  }

  ft.show(details);
  ft.hide(fragmentManager.findFragmentById(R.id.book_list));
  ft.addToBackStack("details"); // Use the back button to return to the search list view.

  ft.commit();
}
 
開發者ID:andviane,項目名稱:google-books-android-viewer,代碼行數:21,代碼來源:BookListActivity.java

示例4: constructItem

import android.graphics.drawable.Drawable; //導入依賴的package包/類
private PieItem constructItem(int width, ButtonType type, Drawable image, int minimumImageSize) {
    ImageView view = new ImageView(mContext);
    view.setImageDrawable(image);
    view.setMinimumWidth(minimumImageSize);
    view.setMinimumHeight(minimumImageSize);
    LayoutParams lp = new LayoutParams(minimumImageSize, minimumImageSize);
    view.setLayoutParams(lp);
    PieItem item = new PieItem(mContext, mGbContext, mPieContainer, 0, width, type, view, mColorInfo);
    item.setOnClickListener(this);
    item.setOnLongPressListener(mLongPressHandler);
    return item;
}
 
開發者ID:WrBug,項目名稱:GravityBox,代碼行數:13,代碼來源:PieController.java

示例5: keyPressed

import android.graphics.drawable.Drawable; //導入依賴的package包/類
protected void keyPressed() {
    if (isEnabled() && isClickable()) {
        Drawable selector = this.mSelector;
        Rect selectorRect = this.mSelectorRect;
        if (selector == null) {
            return;
        }
        if ((isFocused() || touchModeDrawsInPressedState()) && !selectorRect.isEmpty()) {
            View v = getChildAt(this.mSelectedPosition - this.mFirstPosition);
            if (v != null) {
                if (!v.hasFocusable()) {
                    v.setPressed(true);
                } else {
                    return;
                }
            }
            setPressed(true);
            boolean longClickable = isLongClickable();
            Drawable d = selector.getCurrent();
            if (d != null && (d instanceof TransitionDrawable)) {
                if (longClickable) {
                    ((TransitionDrawable) d).startTransition(ViewConfiguration.getLongPressTimeout());
                } else {
                    ((TransitionDrawable) d).resetTransition();
                }
            }
            if (longClickable && !this.mDataChanged) {
                if (this.mPendingCheckForKeyLongPress == null) {
                    this.mPendingCheckForKeyLongPress = new CheckForKeyLongPress(this, null);
                }
                this.mPendingCheckForKeyLongPress.rememberWindowAttachCount();
                postDelayed(this.mPendingCheckForKeyLongPress, (long) ViewConfiguration.getLongPressTimeout());
            }
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:37,代碼來源:AbsHListView.java

示例6: getEmojiDrawable

import android.graphics.drawable.Drawable; //導入依賴的package包/類
private @Nullable Drawable getEmojiDrawable(@Nullable EmojiDrawInfo drawInfo) {
  if (drawInfo == null)  {
    return null;
  }

  final EmojiDrawable drawable = new EmojiDrawable(drawInfo, decodeScale);
  drawInfo.getPage().get().addListener(new FutureTaskListener<Bitmap>() {
    @Override public void onSuccess(final Bitmap result) {
      Util.runOnMain(new Runnable() {
        @Override public void run() {
          drawable.setBitmap(result);
        }
      });
    }

    @Override public void onFailure(ExecutionException error) {
      Log.w(TAG, error);
    }
  });
  return drawable;
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:22,代碼來源:EmojiProvider.java

示例7: loadAlbumCover

import android.graphics.drawable.Drawable; //導入依賴的package包/類
protected void loadAlbumCover(Song song, final ViewHolder holder) {
    if (holder.image == null) return;

    SongGlideRequest.Builder.from(Glide.with(activity), song)
            .checkIgnoreMediaStore(activity)
            .generatePalette(activity).build()
            .into(new PhonographColoredTarget(holder.image) {
                @Override
                public void onLoadCleared(Drawable placeholder) {
                    super.onLoadCleared(placeholder);
                    setColors(getDefaultFooterColor(), holder);
                }

                @Override
                public void onColorReady(int color) {
                    if (usePalette)
                        setColors(color, holder);
                    else
                        setColors(getDefaultFooterColor(), holder);
                }
            });
}
 
開發者ID:aliumujib,項目名稱:Orin,代碼行數:23,代碼來源:SongAdapter.java

示例8: loadMimeIcon

import android.graphics.drawable.Drawable; //導入依賴的package包/類
public static Drawable loadMimeIcon(
        Context context, String mimeType, String authority, String docId, int mode) {

    if (Document.MIME_TYPE_DIR.equals(mimeType)) {
        if (MediaDocumentsProvider.AUTHORITY.equals(authority)) {
            if(docId.startsWith(MediaDocumentsProvider.TYPE_ALBUM)){
                return ContextCompat.getDrawable(context, R.drawable.ic_doc_album);
            }
            else if(docId.startsWith(MediaDocumentsProvider.TYPE_IMAGES_BUCKET)){
                return ContextCompat.getDrawable(context, R.drawable.ic_doc_folder);
            }
            else if(docId.startsWith(MediaDocumentsProvider.TYPE_VIDEOS_BUCKET)){
                return ContextCompat.getDrawable(context, R.drawable.ic_doc_folder);
            }
        }

        if (mode == DocumentsActivity.State.MODE_GRID) {
            return ContextCompat.getDrawable(context, R.drawable.ic_grid_folder);
        } else {
            return ContextCompat.getDrawable(context, R.drawable.ic_doc_folder);
        }
    }

    return loadMimeIcon(context, mimeType);
}
 
開發者ID:gigabytedevelopers,項目名稱:FireFiles,代碼行數:26,代碼來源:IconUtils.java

示例9: onDraw

import android.graphics.drawable.Drawable; //導入依賴的package包/類
@Override
protected void onDraw(Canvas canvas) {
    Drawable[] drawables = getCompoundDrawables();
    if (drawables != null) {
        Drawable drawableLeft = drawables[0];
        if (drawableLeft != null) {
            float textWidth = getPaint().measureText(getText().toString());
            int drawablePadding = getCompoundDrawablePadding();
            int drawableWidth = 0;
            drawableWidth = drawableLeft.getIntrinsicWidth();
            float bodyWidth = textWidth + drawableWidth + drawablePadding;
            canvas.translate((getWidth() - bodyWidth) / 2 -20, 0);
        }
    }
    super.onDraw(canvas);
}
 
開發者ID:ccfish86,項目名稱:sctalk,代碼行數:17,代碼來源:DrawableCenterEditText.java

示例10: onViewClicked

import android.graphics.drawable.Drawable; //導入依賴的package包/類
@OnClick({R.id.start, R.id.red_line, R.id.gray_line})
public void onViewClicked(View view) {
    switch (view.getId()) {
        case R.id.start:
            Bitmap bp = pint1.createSnapshoot();
            Drawable dw = new BitmapDrawable(getResources(),bp);
            im.setImageDrawable(dw);

            break;
        case R.id.red_line:
            break;
        case R.id.gray_line:

            break;
    }
}
 
開發者ID:fengdongfei,項目名稱:CXJPadProject,代碼行數:17,代碼來源:SurroundTestFragment.java

示例11: draw

import android.graphics.drawable.Drawable; //導入依賴的package包/類
public void draw(@NonNull Canvas canvas) {
    super.draw(canvas);
    if (this.mForeground != null) {
        Drawable foreground = this.mForeground;
        if (this.mForegroundBoundsChanged) {
            this.mForegroundBoundsChanged = false;
            Rect selfBounds = this.mSelfBounds;
            Rect overlayBounds = this.mOverlayBounds;
            int w = getRight() - getLeft();
            int h = getBottom() - getTop();
            if (this.mForegroundInPadding) {
                selfBounds.set(0, 0, w, h);
            } else {
                selfBounds.set(getPaddingLeft(), getPaddingTop(), w - getPaddingRight(), h - getPaddingBottom());
            }
            Gravity.apply(this.mForegroundGravity, foreground.getIntrinsicWidth(), foreground.getIntrinsicHeight(), selfBounds, overlayBounds);
            foreground.setBounds(overlayBounds);
        }
        foreground.draw(canvas);
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:22,代碼來源:ForegroundLinearLayout.java

示例12: getOtherButtonBg

import android.graphics.drawable.Drawable; //導入依賴的package包/類
private Drawable getOtherButtonBg(String[] titles, int i) {
    if (titles.length == 1) {
        return mAttrs.otherButtonSingleBackground;
    }
    if (titles.length == 2) {
        switch (i) {
            case 0:
                return mAttrs.otherButtonTopBackground;
            case 1:
                return mAttrs.otherButtonBottomBackground;
        }
    }
    if (titles.length > 2) {
        if (i == 0) {
            return mAttrs.otherButtonTopBackground;
        }
        if (i == (titles.length - 1)) {
            return mAttrs.otherButtonBottomBackground;
        }
        return mAttrs.getOtherButtonMiddleBackground();
    }
    return null;
}
 
開發者ID:hh-in-zhuzhou,項目名稱:ShangHanLun,代碼行數:24,代碼來源:ActionSheet.java

示例13: createFillDrawable

import android.graphics.drawable.Drawable; //導入依賴的package包/類
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Drawable createFillDrawable() {
    StateListDrawable drawable = new StateListDrawable();
    drawable.addState(new int[]{-android.R.attr.state_enabled}, createCircleDrawable(mColorDisabled));
    drawable.addState(new int[]{android.R.attr.state_pressed}, createCircleDrawable(mColorPressed));
    drawable.addState(new int[]{}, createCircleDrawable(mColorNormal));

    if (Util.hasLollipop()) {
        RippleDrawable ripple = new RippleDrawable(new ColorStateList(new int[][]{{}},
                new int[]{mColorRipple}), drawable, null);
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            public void getOutline(View view, Outline outline) {
                outline.setOval(0, 0, view.getWidth(), view.getHeight());
            }
        });
        setClipToOutline(true);
        mBackgroundDrawable = ripple;
        return ripple;
    }

    mBackgroundDrawable = drawable;
    return drawable;
}
 
開發者ID:WeiMei-Tian,項目名稱:editor-sql,代碼行數:25,代碼來源:FloatingActionButton.java

示例14: styleSeekBar

import android.graphics.drawable.Drawable; //導入依賴的package包/類
private void styleSeekBar() {
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
    final Drawable progressDrawable = mSeekBar.getProgressDrawable();
    if (progressDrawable != null) {
      if (progressDrawable instanceof LayerDrawable) {
        LayerDrawable ld = (LayerDrawable) progressDrawable;
        int layers = ld.getNumberOfLayers();
        for (int i = 0; i < layers; i++) {
          ld.getDrawable(i).mutate().setColorFilter(mTintColor, PorterDuff.Mode.SRC_ATOP);
        }
      } else {
        progressDrawable.mutate().setColorFilter(mTintColor, PorterDuff.Mode.SRC_ATOP);
      }
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
      final Drawable thumb = mSeekBar.getThumb();
      if (thumb != null) {
        thumb.mutate().setColorFilter(mTintColor, PorterDuff.Mode.SRC_ATOP);
      }
    }
  }
}
 
開發者ID:Elias33,項目名稱:Quran,代碼行數:24,代碼來源:SeekBarPreference.java

示例15: setSelected

import android.graphics.drawable.Drawable; //導入依賴的package包/類
private void setSelected(boolean selected) {
    final View imageView = itemView.findViewById(R.id.image);

    if (selected) {
        final Drawable selectorOverlay = Util
                .getAlbumItemSelectorOverlay(imageView.getContext());
        imageView.post(new Runnable() {
            @Override
            public void run() {
                imageView.getOverlay().clear();
                if (selectorOverlay != null) {
                    selectorOverlay.setBounds(0, 0,
                            imageView.getWidth(),
                            imageView.getHeight());
                    imageView.getOverlay().add(selectorOverlay);
                }
            }
        });
    } else {
        imageView.post(new Runnable() {
            @Override
            public void run() {
                imageView.getOverlay().clear();
            }
        });
    }
}
 
開發者ID:kollerlukas,項目名稱:Camera-Roll-Android-App,代碼行數:28,代碼來源:FileOperationDialogActivity.java


注:本文中的android.graphics.drawable.Drawable類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。