/** * 加载hintview的容器 */ private void loadHintView(){ addView(mHintView); mHintView.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); ((View) mHintView).setLayoutParams(lp); GradientDrawable gd = new GradientDrawable(); gd.setColor(color); gd.setAlpha(alpha); mHintView.setBackgroundDrawable(gd); mHintViewDelegate.initView(mAdapter == null ? 0 : mAdapter.getCount(), gravity, (HintView) mHintView); }
private LayerDrawable getGradientDrawable(int color, Orientation orientation){ int[] colors = new int[] {color, Color.WHITE}; GradientDrawable drawable1 = new GradientDrawable(orientation, colors); drawable1.setAlpha(125); GradientDrawable drawable2 = new GradientDrawable(); drawable2.setStroke(4, Color.parseColor("#FFFFFF")); drawable2.setColor(Color.TRANSPARENT); return new LayerDrawable(new Drawable[]{drawable1 , drawable2}); }
/** * 初始化GradientDrawable */ private void initGradientDrawable() { mGradientDrawable.setColor(mContext.getResources().getColor( android.R.color.white)); mGradientDrawable.setCornerRadius(dip2px(1)); mGradientDrawable.setStroke(dip2px(1), mContext.getResources() .getColor(android.R.color.holo_blue_light)); mGradientDrawable.setAlpha(128); }
@Override public Void call() throws Exception { ViewGroup.LayoutParams layoutParams = getLayoutParams(); mOriginalThumbHeight = mThumb.getIntrinsicHeight(); gradientDrawable.setSize(mOriginalThumbHeight / 3, mOriginalThumbHeight / 3); gradientDrawable.setAlpha(mThumbAlpha); setThumb(gradientDrawable); if (layoutParams.height < mOriginalThumbHeight) layoutParams.height = mOriginalThumbHeight; setupProgressBackground(); return null; } });
gradientDrawable.setColor(mIsEnabled ? mThumbColor : Color.LTGRAY); gradientDrawable.setDither(true); gradientDrawable.setAlpha(mThumbAlpha); setThumb(gradientDrawable); break; gradientDrawable.setColor(mIsEnabled ? mThumbColor : Color.LTGRAY); gradientDrawable.setDither(true); gradientDrawable.setAlpha(mThumbAlpha); setThumb(gradientDrawable); break;
backu.setColor(textNormal); backu.setCornerRadius(12 * res.getDisplayMetrics().scaledDensity); backu.setAlpha(255); GradientDrawable backd = new GradientDrawable(); backd.setColor(colorAccent); backd.setCornerRadius(12 * res.getDisplayMetrics().scaledDensity); backd.setAlpha(96); back.addState(new int[]{-android.R.attr.state_enabled}, backd); back.addState(new int[]{-android.R.attr.state_checked}, backu); trk.setColor(colorAccent); trk.setCornerRadius(10 * density); trk.setAlpha(128); GradientDrawable backu = new GradientDrawable(); backu.setColor(textNormal); backu.setCornerRadius(12 * res.getDisplayMetrics().scaledDensity); backu.setAlpha(192); back.addState(new int[]{-android.R.attr.state_checked}, backu); back.addState(StateSet.WILD_CARD, trk);
gradientDrawable.setColor(mIsEnabled ? mThumbColor : Color.LTGRAY); gradientDrawable.setDither(true); gradientDrawable.setAlpha(mThumbAlpha); setThumb(gradientDrawable);
light_back_drawable.setAlpha(255 - ((int) (value * 255))); light_back_drawable.draw(canvas);