微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android.graphics.drawable.GradientDrawable的实例源码

项目:GitHub    文件DrawableHelper.java   
/**被按下时的背景*/
public static Drawable createCornerBgpressed(Context c) {
    SizeHelper.prepare(c);

    // prepare
    int strokeWidth = SizeHelper.fromPxWidth(1);
    int roundRadius = SizeHelper.fromPxWidth(6);
    int strokeColor = Color.parseColor("#ffc9c9cb");
    int fillColor = Color.parseColor("#afc9c9cb");

    GradientDrawable gd = new GradientDrawable();
    gd.setColor(fillColor);
    gd.setCornerRadius(roundRadius);
    gd.setstroke(strokeWidth,strokeColor);

    return gd;
}
项目:OSchina_resources_android    文件IdentityView.java   
private void initBorder() {
//        if (mWipeOffBorder || mIdentity == null || !mIdentity.officialMember) {
//            mDrawable = null;
//            setBackground(null);
//            return;
//        }

        if (mDrawable == null) {
            float radius = 4f;

            GradientDrawable gradientDrawable = new GradientDrawable();
            gradientDrawable.setGradientType(GradientDrawable.LINEAR_GRADIENT);
            gradientDrawable.setShape(GradientDrawable.RECTANGLE);
            gradientDrawable.setDither(true);
            gradientDrawable.setstroke(stroke_SIZE,mColor);
            gradientDrawable.setCornerRadius(radius);

            mDrawable = gradientDrawable;
        } else {
            mDrawable.setstroke(stroke_SIZE,mColor);
        }

        setBackground(mDrawable);
    }
项目:GitHub    文件OverlappedWidget.java   
@Override
protected void drawCurrentPageShadow(Canvas canvas) {
    canvas.save();
    GradientDrawable shadow;
    if (actiondownX > mScreenWidth >> 1) {
        shadow = mBackShadowDrawableLR;
        shadow.setBounds((int) (mScreenWidth + touch_down - 5),(int) (mScreenWidth + touch_down + 5),mScreenHeight);

    } else {
        shadow = mBackShadowDrawableRL;
        shadow.setBounds((int) (touch_down - 5),(int) (touch_down + 5),mScreenHeight);
    }
    shadow.draw(canvas);
    try {
        canvas.restore();
    } catch (Exception e) {

    }
}
项目:silly-android    文件Coloring.java   
/**
 * Creates a new {@link rippledrawable} introduced in Lollipop.
 *
 * @param normalColor  Color for the idle/normal state
 * @param rippleColor  Color for the ripple effect
 * @param bounds       Clipping bounds for the ripple state. Set to {@code null} to get a borderless ripple
 * @param cornerRadius Set to round the corners on rectangular drawables,0 to disable
 * @return A fully colored rippledrawable,new instance each time
 */
@NonNull
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
public static rippledrawable createrippledrawable(@ColorInt final int normalColor,@ColorInt final int rippleColor,@Nullable final Rect bounds,@IntRange(from = 0) final int cornerRadius) {
    Drawable maskDrawable = null;
    if (bounds != null) {
        // clip color is white
        maskDrawable = createColoredDrawable(Color.WHITE,bounds);
        if (maskDrawable instanceof GradientDrawable) {
            ((GradientDrawable) maskDrawable).setCornerRadius(cornerRadius);
        }
        maskDrawable.setBounds(bounds);
    }

    Drawable normalStateDrawable = null;
    // transparent has no idle state
    if (normalColor != Color.TRANSPARENT) {
        normalStateDrawable = createColoredDrawable(normalColor,bounds);
        if (normalStateDrawable instanceof GradientDrawable) {
            ((GradientDrawable) normalStateDrawable).setCornerRadius(cornerRadius);
        }
    }

    return new rippledrawable(ColorStateList.valueOf(rippleColor),normalStateDrawable,maskDrawable);
}
项目:RLibrary    文件ViewfinderView.java   
public ViewfinderView(Context context,AttributeSet attrs) {
    super(context,attrs);
    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint2 = new Paint(Paint.ANTI_ALIAS_FLAG);
    Resources resources = getResources();
    maskColor = Color.parseColor("#60000000");//resources.getColor(R.color.viewfinder_mask);
    resultColor = Color.parseColor("#b0000000");//resources.getColor(R.color.result_view);

    // GradientDrawable、lineDrawable
    mRect = new Rect();
    int left = Color.RED;//getResources().getColor(R.color.lightgreen);
    //getResources().getColor(R.color.green);
    //mCenterColor = Color.RED;
    setCenterColor(Color.RED);
    int right = Color.RED;//getResources().getColor(R.color.lightgreen);
    //lineDrawable = resources.getDrawable(R.drawable.zx_code_line);
    mDrawable = new GradientDrawable(
            GradientDrawable.Orientation.LEFT_RIGHT,new int[]{left,left,mCenterColor,right,right});

    scannerAlpha = 0;
    possibleResultPoints = new ArrayList<>(5);
}
项目:Cable-Android    文件LEDColorListPreference.java   
private void setPreviewColor(@NonNull String value) {
  int color;

  switch (value) {
    case "green":   color = getContext().getResources().getColor(R.color.green_500);   break;
    case "red":     color = getContext().getResources().getColor(R.color.red_500);     break;
    case "blue":    color = getContext().getResources().getColor(R.color.blue_500);    break;
    case "yellow":  color = getContext().getResources().getColor(R.color.yellow_500);  break;
    case "cyan":    color = getContext().getResources().getColor(R.color.cyan_500);    break;
    case "magenta": color = getContext().getResources().getColor(R.color.pink_500);    break;
    case "white":   color = getContext().getResources().getColor(R.color.white);       break;
    default:        color = getContext().getResources().getColor(R.color.transparent); break;
  }

  if (colorImageView != null) {
    GradientDrawable drawable = new GradientDrawable();
    drawable.setShape(GradientDrawable.oval);
    drawable.setColor(color);

    colorImageView.setimageDrawable(drawable);
  }
}
项目:StarchWindow    文件FlatToast.java   
public FlatToast(Context context) {
    super(context);
    mContext = context;

    //toast text
    textView = new TextView(context);
    textView.setTextColor(Color.WHITE);
    textView.setTextSize(17);
    textView.setPadding(Utils.dip2px(context,15),Utils.dip2px(context,8),8));

    //toast background
    gradientDrawable = new GradientDrawable();
    gradientDrawable.setColor(Color.parseColor("#212121"));
    gradientDrawable.setAlpha(200);
    gradientDrawable.setCornerRadius(Utils.dip2px(context,10));
}
项目:DereHelper    文件MultiLineChooseLayout.java   
private void updateDrawable(int strokeColor) {

            int mbackgroundColor;
            if (isChecked) {
                mbackgroundColor = selectedBackgroundColor;
            } else {
                mbackgroundColor = backgroundColor;
            }

            GradientDrawable drawable = new GradientDrawable();
            drawable.setCornerRadii(mRadius);
            drawable.setColor(mbackgroundColor);
            drawable.setstroke(mstrokeWidth,strokeColor);

            if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
                this.setBackgroundDrawable(drawable);
            } else {
                this.setBackground(drawable);
            }
        }
项目:ultrasonic    文件MenuDrawer.java   
protected GradientDrawable.Orientation getDropShadowOrientation() {
    // Gets the orientation for the static and sliding drawer. The overlay drawer provides its own implementation.
    switch (getPosition()) {
        case TOP:
            return GradientDrawable.Orientation.BottOM_TOP;

        case RIGHT:
            return GradientDrawable.Orientation.LEFT_RIGHT;

        case BottOM:
            return GradientDrawable.Orientation.TOP_BottOM;

        default:
            return GradientDrawable.Orientation.RIGHT_LEFT;
    }
}
项目:FriendBook    文件SuperConfig.java   
private Drawable getGradientDrawable(float mCornerRadius,int mstrokeColor,int mSolidColor,int mstrokeWidth,float mDashWidth,float mDashGap,float mTopLefTradius,float mTopRighTradius,float mBottomLefTradius,float mBottomrighTradius) {
    GradientDrawable gradientDrawable = new GradientDrawable();
    gradientDrawable.setColor(mSolidColor);
    gradientDrawable.setstroke(mstrokeWidth,mstrokeColor,mDashWidth,mDashGap);
    float[] radius = {mTopLefTradius,mTopLefTradius,mTopRighTradius,mBottomrighTradius,mBottomLefTradius,mBottomLefTradius};

    if (mCornerRadius == DEFAULT_CORNER_RADIUS) {
        gradientDrawable.setCornerRadii(radius);
    } else {
        gradientDrawable.setCornerRadius(mCornerRadius);
    }
    return gradientDrawable;
}
项目:BlackList    文件Utils.java   
/**
 * Sets the background color of the drawable
 **/
public static void setDrawableColor(Context context,Drawable drawable,@AttrRes int colorAttrRes) {
    int colorRes = getResourceId(context,colorAttrRes);
    int color = ContextCompat.getColor(context,colorRes);
    if (drawable instanceof ShapeDrawable) {
        ((ShapeDrawable) drawable).getPaint().setColor(color);
    } else if (drawable instanceof GradientDrawable) {
        ((GradientDrawable) drawable).setColor(color);
    } else if (drawable instanceof ColorDrawable) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            ((ColorDrawable) drawable).setColor(color);
        }
    } else if (drawable instanceof RotateDrawable) {
        setDrawableColor(context,((RotateDrawable) drawable).getDrawable(),colorAttrRes);
    }
}
项目:Material-Motion    文件DotsFragment.java   
private AnimatorSet morPHParent(int duration){
    GradientDrawable drawable=GradientDrawable.class.cast(parent.getBackground());
    int endValue=isFolded?getResources().getDimensionPixelOffset(R.dimen.morph_radius):0;
    ObjectAnimator cornerAnimation = ObjectAnimator.ofFloat(drawable,"cornerRadius",endValue);
    endValue=isFolded?parent.getHeight()/2:parent.getHeight()*2;
    ValueAnimator heightAnimation = ValueAnimator.ofInt(parent.getHeight(),endValue);
    heightAnimation.addUpdateListener(valueAnimator-> {
        int val = (Integer) valueAnimator.getAnimatedValue();
        ViewGroup.LayoutParams layoutParams = parent.getLayoutParams();
        layoutParams.height = val;
        parent.setLayoutParams(layoutParams);
    });
    cornerAnimation.setDuration(duration);
    heightAnimation.setDuration(duration);
    AnimatorSet set=new AnimatorSet();
    set.playTogether(cornerAnimation,heightAnimation);
    return set;
}
项目:BookPage    文件BookPageView.java   
/**
 * 绘制A区域水平翻页阴影
 * @param canvas
 */
private void drawPathAHorizontalShadow(Canvas canvas,Path pathA){
    canvas.restore();
    canvas.save();
    canvas.clipPath(pathA,Region.Op.INTERSECT);

    int maxShadowWidth = 30;//阴影矩形最大的宽度
    int left = (int) (a.x - Math.min(maxShadowWidth,(rPathAShadowdis/2)));
    int right = (int) (a.x);
    int top = 0;
    int bottom = viewHeight;
    GradientDrawable gradientDrawable = drawableHorizontalLowerRight;
    gradientDrawable.setBounds(left,top,bottom);

    float mdegrees = (float) Math.todegrees(Math.atan2(f.x-a.x,f.y-h.y));
    canvas.rotate(mdegrees,a.x,a.y);
    gradientDrawable.draw(canvas);
}
项目:BookPage    文件CoverPageView.java   
private void init(Context context){
    defaultWidth = 600;
    defaultHeight = 1000;
    pageNum = 1;
    scrollPageLeft = 0;
    scrollTime = 300;
    touchStyle = TOUCH_RIGHT;
    pageState = PAGE_STAY;

    touchPoint = new MyPoint(-1,-1);
    mScroller = new Scroller(context,new LinearInterpolator());

    int[] mBackShadowColors = new int[] { 0x66000000,0x00000000};
    shadowDrawable = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT,mBackShadowColors);
    shadowDrawable.setGradientType(GradientDrawable.LINEAR_GRADIENT);
}
项目:XERUNG    文件Switch.java   
public void changeBackground() {
    if (iSchecked) {
        if (!isInEditMode()) {
            setBackgroundResource(R.drawable.background_checkBox);
            LayerDrawable layer = (LayerDrawable) getBackground();
            GradientDrawable shape = (GradientDrawable) layer
                    .findDrawableByLayerId(R.id.shape_bacground);
            shape.setColor(backgroundColor);
        }

    } else {
        if (!isInEditMode()) {
            setBackgroundResource(R.drawable.background_switch_ball_uncheck);
        }
    }
}
项目:FlickLauncher    文件HeaderElevationController.java   
public ControllerV16(View header) {
    Resources res = header.getContext().getResources();
    mScrollToElevation = res.getDimension(R.dimen.all_apps_header_scroll_to_elevation);

    mShadow = new View(header.getContext());
    mShadow.setBackground(new GradientDrawable(
            GradientDrawable.Orientation.TOP_BottOM,new int[] {0x1E000000,0x00000000}));
    mShadow.setAlpha(0);

    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.MATCH_PARENT,res.getDimensionPixelSize(R.dimen.all_apps_header_shadow_height));
    lp.topMargin = ((FrameLayout.LayoutParams) header.getLayoutParams()).height;

    ((ViewGroup) header.getParent()).addView(mShadow,lp);
}
项目:TextReader    文件OverlappedWidget.java   
@Override
protected void drawCurrentPageShadow(Canvas canvas) {
    canvas.save();
    GradientDrawable shadow;
    if (actiondownX > mScreenWidth >> 1) {
        shadow = mBackShadowDrawableLR;
        shadow.setBounds((int) (mScreenWidth + touch_down - 5),mScreenHeight);
    }
    shadow.draw(canvas);
    try {
        canvas.restore();
    } catch (Exception e) {

    }
}
项目:proSwipeButton    文件ProSwipeButton.java   
@Override
protected void onFinishInflate() {
    super.onFinishInflate();

    contentContainer = view.findViewById(R.id.relativeLayout_swipeBtn_contentContainer);
    arrowHintContainer = view.findViewById(R.id.linearLayout_swipeBtn_hintContainer);
    contentTv = view.findViewById(R.id.tv_btnText);
    arrow1 = view.findViewById(R.id.iv_arrow1);
    arrow2 = view.findViewById(R.id.iv_arrow2);

    tintArrowHint();
    contentTv.setText(btnText);
    contentTv.setTextColor(textColorInt);
    contentTv.setTextSize(TypedValue.COMPLEX_UNIT_PX,textSize);
    gradientDrawable = new GradientDrawable();
    gradientDrawable.setShape(GradientDrawable.RECTANGLE);
    gradientDrawable.setCornerRadius(btnRadius);
    setBackgroundColor(bgColorInt);
    updateBackground();
    setupTouchListener();
}
项目:zabbkit-android    文件EventsAdapter.java   
@Override
public void onBindViewHolder(WearableListView.ViewHolder holder,int position) {
    // retrieve the text view
    ItemViewHolder itemHolder = (ItemViewHolder) holder;
    TextView view = itemHolder.descriptionText;
    // replace text contents
    view.setText(mDataset.get(position).getString("description"));
    // replace list item's Metadata
    holder.itemView.setTag(position);

    ImageView mCircle = itemHolder.priorityCircleImage;
    int result;
    int prior = Integer.valueOf(mDataset.get(position).getString("priority"));
    switch (prior) {
        case Constants.STATE_NOT_CLASSIFIED:
            result = R.color.not_classified_color;
            break;
        case Constants.STATE_@R_143_4045@ION:
            result = R.color.@R_143_4045@ion_color;
            break;
        case Constants.STATE_WARNING:
            result = R.color.warning_color;
            break;
        case Constants.STATE_AVERAGE:
            result = R.color.average_color;
            break;
        case Constants.STATE_HIGH:
            result = R.color.high_color;
            break;
        case Constants.STATE_disASTER:
            result = R.color.disaster_color;
            break;
        default:
            result = R.color.not_classified_color;
            break;
    }
    ((GradientDrawable) mCircle.getDrawable()).setColor(mContext.getResources().getColor(result));

}
项目:simpledialogFragments    文件ColorView.java   
private Drawable createBackgroundColorDrawable() {
    GradientDrawable mask = new GradientDrawable();
    mask.setShape(GradientDrawable.oval);
    if (mOutlinewidth != 0) {
        mask.setstroke(mOutlinewidth,isColorDark(mColor) ? Color.WHITE : Color.BLACK);
    }
    mask.setColor(mColor);
    return mask;
}
项目:dotsindicator    文件DotsIndicator.java   
private void setUpCircleColors(int color) {
  if (dots != null) {
    for (ImageView elevationItem : dots) {
      ((GradientDrawable) elevationItem.getBackground()).setColor(color);
    }
  }
}
项目:sealtalk-android-master    文件DragPointView.java   
/**
 * @param radius 圆角角度
 * @param color  填充颜色
 * @return StateListDrawable 对象
 * @author zy
 */
public static StateListDrawable createStateListDrawable(int radius,int color) {
    StateListDrawable bg = new StateListDrawable();
    GradientDrawable gradientStatenormal = new GradientDrawable();
    gradientStatenormal.setColor(color);
    gradientStatenormal.setShape(GradientDrawable.RECTANGLE);
    gradientStatenormal.setCornerRadius(50);
    gradientStatenormal.setstroke(0,0);
    bg.addState(View.EMPTY_STATE_SET,gradientStatenormal);
    return bg;
}
项目:fuckView    文件RedBoundPopupWindow.java   
@Override
protected View onCreateView(Context context) {
    absoluteLayout = new AbsoluteLayout(context);
    GradientDrawable gd = new GradientDrawable();
    gd.setstroke(4,Color.RED);
    absoluteLayout.setBackgroundDrawable(gd);
    return absoluteLayout;
}
项目:AndroidUiKit    文件IDividerItemdecoration.java   
/**
 * Creates a divider {@link RecyclerView.Itemdecoration} that can be used with a
 * {@link linearlayoutmanager}.
 *
 * @param context Current context,it will be used to access resources.
 * @param orientation Divider orientation. Should be {@link #HORIZONTAL} or {@link #VERTICAL}.
 */
public IDividerItemdecoration(Context context,int orientation) {
    final TypedArray a = context.obtainStyledAttributes(ATTRS);
    mDivider = new GradientDrawable();
    //认divider 1dp
    mVerticalDividerHeight = DimenUtil.dp2px(context,1);
    mHorizontalDividerWidth = DimenUtil.dp2px(context,1);
    mDividerColor = Color.parseColor("lightgrey");
    a.recycle();
    setorientation(orientation);
}
项目:GitHub    文件TextBadgeItem.java   
/**
 * @param context to fetch color
 * @return return the background drawable
 */
private GradientDrawable getBadgeDrawable(Context context) {
    GradientDrawable shape = new GradientDrawable();
    shape.setShape(GradientDrawable.RECTANGLE);
    shape.setCornerRadius(context.getResources().getDimensionPixelSize(R.dimen.badge_corner_radius));
    shape.setColor(getBackgroundColor(context));
    shape.setstroke(getBorderWidth(),getBorderColor(context));
    return shape;
}
项目:ExpandButton    文件ExpandButtonLayout.java   
/**
 * 设置圆角背景
 */
private void initBackGround(){
    int fillColor = getResources().getColor(R.color.colorPrimary);
    GradientDrawable gd = new GradientDrawable();//创建drawable
    gd.setColor(fillColor);
    //圆角半径等于高度的一半,合成之后是一个完整的圆
    gd.setCornerRadius(allHeight/2f);
    gd.getPadding(new Rect(0,0));
    setBackground(gd);
}
项目:ColorView    文件ColorViewHelper.java   
private boolean updatepressed(boolean forcetoColorMode) {
    if (forcetoColorMode) {
        mDrawablepressed = createDrawable(mDrawablepressed,mBgColorpressed,mBdColorpressed,true);
    } else {
        if (mDrawablepressed instanceof GradientDrawable) {
            mDrawablepressed = createDrawable(mDrawablepressed,false);
        } else {
            return false;
        }
    }

    return true;
}
项目:PlusGram    文件ProfileActivity.java   
private void updateActionBarBG(){
    SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS,AndroidUtilities.THEME_PREFS_MODE);
    int def = themePrefs.getInt("themeColor",AndroidUtilities.defColor);
    int hColor = themePrefs.getInt("profileHeaderColor",def);
    actionBar.setBackgroundColor(hColor);
    listView.setGlowColor(hColor);
    topViewColor = hColor;
    int val = themePrefs.getInt("profileHeaderGradient",0);
    if (val > 0) {
        topViewColor = 0x00000000;
        int gradColor = themePrefs.getInt("profileHeaderGradientColor",def);
        GradientDrawable.Orientation go;
        switch (val) {
            case 2:
                go = GradientDrawable.Orientation.LEFT_RIGHT;
                break;
            case 3:
                go = GradientDrawable.Orientation.TL_BR;
                break;
            case 4:
                go = GradientDrawable.Orientation.BL_TR;
                break;
            default:
                go = GradientDrawable.Orientation.TOP_BottOM;
                topViewColor = gradColor;
        }
        int[] colors = new int[]{hColor,gradColor};
        GradientDrawable actionBarGradient = new GradientDrawable(go,colors);
        actionBar.setBackgroundDrawable(actionBarGradient);
    }
    topView.setBackgroundColor(topViewColor);
}
项目:FlipProgressDialog    文件BackgroundView.java   
public static Drawable setBackground(View v,int color,int borderColor,int r,int borderstroke) {
    GradientDrawable shape = new GradientDrawable();
    shape.setShape(GradientDrawable.RECTANGLE);
    shape.setCornerRadii(new float[] { r,r,r });
    shape.setColor(color);
    shape.setstroke(borderstroke,borderColor);
    return shape;
}
项目:HeadlineNews    文件SelectorFactory.java   
private GradientDrawable getItemShape(int shape,int cornerRadius,int solidColor,int strokeWidth,int strokeColor) {
    GradientDrawable drawable = new GradientDrawable();
    drawable.setShape(shape);
    drawable.setstroke(strokeWidth,strokeColor);
    drawable.setCornerRadius(cornerRadius);
    drawable.setColor(solidColor);
    return drawable;
}
项目:GitHub    文件WoWoLayerListColorAnimation.java   
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");
}
项目:Tangram-Android    文件BannerView.java   
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;
}
项目:cwac-crossport    文件FloatingActionButtonImpl.java   
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);
}
项目:boohee_v5.6    文件WeightDetailAdapter.java   
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;
}
项目:NovelReader    文件CoverPageAnim.java   
public CoverPageAnim(int w,int h,View view,OnPagechangelistener listener) {
    super(w,h,view,listener);
    mSrcRect = new Rect(0,mViewWidth,mViewHeight);
    mDestRect = new Rect(0,mViewHeight);
    int[] mBackShadowColors = new int[] { 0x66000000,0x00000000};
    mBackShadowDrawableLR = new GradientDrawable(
            GradientDrawable.Orientation.LEFT_RIGHT,mBackShadowColors);
    mBackShadowDrawableLR.setGradientType(GradientDrawable.LINEAR_GRADIENT);
}
项目:underlx    文件LineRecyclerViewAdapter.java   
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);
    }
}
项目:NodeET    文件CategoryListFragment.java   
CategoryViewHolder(View itemView) {
    super(itemView);
    //第一个参数是注解所在的对象。第二个参数是View。
    ButterKnife.bind(this,itemView);
    icon.setTypeface(Typefaces.getAwesomeFont(getContext()));
    iconBackground = (GradientDrawable) icon.getBackground();
}
项目:RetroMusicPlayer    文件DrawableGradient.java   
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();
    }
}
项目:stynico    文件ColorPointHintView.java   
@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(),dump.v.Util.dip2px(getContext(),8));
       return dot_focus;
   }
项目:ColorView    文件ColorViewHelper.java   
private boolean updateChecked(boolean forcetoColorMode) {
    if (forcetoColorMode) {
        mDrawableChecked = createDrawable(mDrawableChecked,mBgColorChecked,mBdColorChecked,true);
    } else {
        if (mDrawableChecked instanceof GradientDrawable) {
            mDrawableChecked = createDrawable(mDrawableChecked,false);
        } else {
            return false;
        }
    }

    return true;
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。