当前位置: 首页>>代码示例>>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;未经允许,请勿转载。