private void setColors(View view, int[] colors) {
Drawable drawable = view.getBackground();
if (drawable instanceof LayerDrawable) {
LayerDrawable layerDrawable = (LayerDrawable) drawable;
for (int i = 0; i < colors.length; i++) if (layerDrawable.getDrawable(i) instanceof GradientDrawable) ((GradientDrawable) layerDrawable.getDrawable(i)).setColor(colors[i]);
} else Log.w(TAG, "Drawable of view must be LayerDrawable in WoWoLayerListColorAnimation");
}
java类android.graphics.drawable.GradientDrawable的实例源码
WoWoLayerListColorAnimation.java 文件源码
项目:GitHub
阅读 25
收藏 0
点赞 0
评论 0
BannerView.java 文件源码
项目:Tangram-Android
阅读 28
收藏 0
点赞 0
评论 0
private GradientDrawable getGradientDrawable(int color, float radius) {
GradientDrawable gradientDrawable = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP,
new int[]{color, color});
gradientDrawable.setShape(GradientDrawable.OVAL);
gradientDrawable.setCornerRadius(radius);
return gradientDrawable;
}
FloatingActionButtonImpl.java 文件源码
项目:cwac-crossport
阅读 35
收藏 0
点赞 0
评论 0
void setBackgroundDrawable(ColorStateList backgroundTint,
PorterDuff.Mode backgroundTintMode, int rippleColor, int borderWidth) {
// Now we need to tint the original background with the tint, using
// an InsetDrawable if we have a border width
mShapeDrawable = DrawableCompat.wrap(createShapeDrawable());
DrawableCompat.setTintList(mShapeDrawable, backgroundTint);
if (backgroundTintMode != null) {
DrawableCompat.setTintMode(mShapeDrawable, backgroundTintMode);
}
// Now we created a mask Drawable which will be used for touch feedback.
GradientDrawable touchFeedbackShape = createShapeDrawable();
// We'll now wrap that touch feedback mask drawable with a ColorStateList. We do not need
// to inset for any border here as LayerDrawable will nest the padding for us
mRippleDrawable = DrawableCompat.wrap(touchFeedbackShape);
DrawableCompat.setTintList(mRippleDrawable, createColorStateList(rippleColor));
final Drawable[] layers;
if (borderWidth > 0) {
mBorderDrawable = createBorderDrawable(borderWidth, backgroundTint);
layers = new Drawable[] {mBorderDrawable, mShapeDrawable, mRippleDrawable};
} else {
mBorderDrawable = null;
layers = new Drawable[] {mShapeDrawable, mRippleDrawable};
}
mContentBackground = new LayerDrawable(layers);
mShadowDrawable = new ShadowDrawableWrapper(
mView.getContext(),
mContentBackground,
mShadowViewDelegate.getRadius(),
mElevation,
mElevation + mPressedTranslationZ);
mShadowDrawable.setAddPaddingForCorners(false);
mShadowViewDelegate.setBackgroundDrawable(mShadowDrawable);
}
WeightDetailAdapter.java 文件源码
项目:boohee_v5.6
阅读 26
收藏 0
点赞 0
评论 0
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(this.context).inflate(R.layout.jm, parent, false);
}
final ScaleIndex itemData = (ScaleIndex) getItem(position);
TextView amount = (TextView) convertView.findViewById(R.id.tv_amount);
TextView level = (TextView) convertView.findViewById(R.id.tv_level);
((TextView) convertView.findViewById(R.id.tv_name)).setText(itemData.getName());
amount.setText(itemData.getValueWithUnit());
GradientDrawable drawable = new GradientDrawable();
drawable.setColor(ViewCompat.MEASURED_SIZE_MASK);
drawable.setCornerRadius(this.outerR[0]);
drawable.setStroke(1, itemData.getColor());
level.setBackgroundDrawable(drawable);
level.setTextColor(itemData.getColor());
level.setText(itemData.getLevelName());
if (itemData instanceof FakeIndex) {
convertView.setOnClickListener(null);
} else {
convertView.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
WeightDetailAdapter.this.mFragment.getDialog().getWindow()
.setWindowAnimations(R.style.df);
ScaleIndexActivity.startActivity(WeightDetailAdapter.this.context,
WeightDetailAdapter.this.mRecord, itemData.getName());
}
});
}
return convertView;
}
CoverPageAnim.java 文件源码
项目:NovelReader
阅读 25
收藏 0
点赞 0
评论 0
public CoverPageAnim(int w, int h, View view, OnPageChangeListener listener) {
super(w, h, view, listener);
mSrcRect = new Rect(0, 0, mViewWidth, mViewHeight);
mDestRect = new Rect(0, 0, mViewWidth, mViewHeight);
int[] mBackShadowColors = new int[] { 0x66000000,0x00000000};
mBackShadowDrawableLR = new GradientDrawable(
GradientDrawable.Orientation.LEFT_RIGHT, mBackShadowColors);
mBackShadowDrawableLR.setGradientType(GradientDrawable.LINEAR_GRADIENT);
}
LineRecyclerViewAdapter.java 文件源码
项目:underlx
阅读 23
收藏 0
点赞 0
评论 0
private void setDownGradient(final ViewHolder holder) {
GradientDrawable gd = new GradientDrawable(
GradientDrawable.Orientation.LEFT_RIGHT,
new int[]{holder.mItem.color, darkerColor(holder.mItem.color)});
if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
holder.mView.setBackgroundDrawable(gd);
} else {
holder.mView.setBackground(gd);
}
}
CategoryListFragment.java 文件源码
项目:NodeET
阅读 23
收藏 0
点赞 0
评论 0
CategoryViewHolder(View itemView) {
super(itemView);
//第一个参数是注解所在的对象。第二个参数是View。
ButterKnife.bind(this, itemView);
icon.setTypeface(Typefaces.getAwesomeFont(getContext()));
iconBackground = (GradientDrawable) icon.getBackground();
}
DrawableGradient.java 文件源码
项目:RetroMusicPlayer
阅读 26
收藏 0
点赞 0
评论 0
public DrawableGradient(Orientation orientations, int[] colors, int shape) {
super(orientations, colors);
try {
setShape(shape);
setGradientType(GradientDrawable.LINEAR_GRADIENT);
setCornerRadius(0);
} catch (Exception e) {
e.printStackTrace();
}
}
ColorPointHintView.java 文件源码
项目:stynico
阅读 24
收藏 0
点赞 0
评论 0
@Override
public Drawable makeFocusDrawable()
{
GradientDrawable dot_focus = new GradientDrawable();
dot_focus.setColor(focusColor);
dot_focus.setCornerRadius(dump.v.Util.dip2px(getContext(), 4));
dot_focus.setSize(dump.v.Util.dip2px(getContext(), 8), dump.v.Util.dip2px(getContext(), 8));
return dot_focus;
}
ColorViewHelper.java 文件源码
项目:ColorView
阅读 26
收藏 0
点赞 0
评论 0
private boolean updateChecked(boolean forceToColorMode) {
if (forceToColorMode) {
mDrawableChecked = createDrawable(mDrawableChecked, mBgColorChecked, mBdColorChecked, true);
} else {
if (mDrawableChecked instanceof GradientDrawable) {
mDrawableChecked = createDrawable(mDrawableChecked, mBgColorChecked, mBdColorChecked, false);
} else {
return false;
}
}
return true;
}