Java Code Examples for android.graphics.drawable.NinePatchDrawable#setColorFilter()

The following examples show how to use android.graphics.drawable.NinePatchDrawable#setColorFilter() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FloatingDrawerView.java    From FastAccess with GNU General Public License v3.0 6 votes vote down vote up
@SuppressLint("InflateParams")
@Override public void onShow(@NonNull WindowManager windowManager, @NonNull View view, @NonNull FolderModel folder) {
    this.windowManager = windowManager;
    Context context = view.getContext();
    drawerHolder = new AppDrawerHolder(LayoutInflater.from(view.getContext()).inflate(R.layout.floating_folder_layout, null, false), this);
    adapter = new FloatingFolderAppsAdapter(new ArrayList<AppsModel>(), getPresenter(), false);
    drawerHolder.recycler.setAdapter(adapter);
    drawerHolder.emptyText.setText(R.string.no_apps);
    drawerHolder.recycler.setEmptyView(drawerHolder.emptyText);
    drawerHolder.folderName.setText(folder.getFolderName());
    NinePatchDrawable drawable = (NinePatchDrawable) drawerHolder.appDrawer.getBackground();
    drawable.setColorFilter(new PorterDuffColorFilter(folder.getColor(),
            PorterDuff.Mode.MULTIPLY));
    setupParams(windowManager);
    appsLoader = new SelectedAppsLoader(context, folder.getId());
    appsLoader.registerListener(folder.hashCode(), getPresenter());
    appsLoader.startLoading();
}
 
Example 2
Source File: LineView.java    From AndroidCharts with MIT License 6 votes vote down vote up
/**
 * @param canvas The canvas you need to draw on.
 * @param point The Point consists of the x y coordinates from left bottom to right top.
 * Like is
 *
 * 3
 * 2
 * 1
 * 0 1 2 3 4 5
 */
private void drawPopup(Canvas canvas, float num, Point point, int PopupColor) {
    String numStr = showFloatNumInPopup ? String.valueOf(num) : String.valueOf(Math.round(num));
    boolean singularNum = (numStr.length() == 1);
    int sidePadding = MyUtils.dip2px(getContext(), singularNum ? 8 : 5);
    int x = point.x;
    int y = point.y - MyUtils.dip2px(getContext(), 5);
    Rect popupTextRect = new Rect();
    popupTextPaint.getTextBounds(numStr, 0, numStr.length(), popupTextRect);
    Rect r = new Rect(x - popupTextRect.width() / 2 - sidePadding, y
            - popupTextRect.height()
            - bottomTriangleHeight
            - popupTopPadding * 2
            - popupBottomMargin, x + popupTextRect.width() / 2 + sidePadding,
            y + popupTopPadding - popupBottomMargin + popupBottomPadding);

    NinePatchDrawable popup =
            (NinePatchDrawable) getResources().getDrawable(R.drawable.popup_white);
    popup.setColorFilter(new PorterDuffColorFilter(PopupColor, PorterDuff.Mode.MULTIPLY));
    popup.setBounds(r);
    popup.draw(canvas);
    canvas.drawText(numStr, x, y - bottomTriangleHeight - popupBottomMargin, popupTextPaint);
}
 
Example 3
Source File: SeekBarCompat.java    From droidddle with Apache License 2.0 5 votes vote down vote up
/***
 * Method called from APIs below 21 to setup Progress Color
 */
private void setupProgressColor() {
    //load up the drawable and apply color
    LayerDrawable ld = (LayerDrawable) getProgressDrawable();
    ScaleDrawable shape = (ScaleDrawable) (ld.findDrawableByLayerId(android.R.id.progress));
    shape.setColorFilter(mProgressColor, PorterDuff.Mode.SRC_IN);

    //set the background to transparent
    NinePatchDrawable ninePatchDrawable = (NinePatchDrawable) (ld.findDrawableByLayerId(android.R.id.background));
    ninePatchDrawable.setColorFilter(Color.TRANSPARENT, PorterDuff.Mode.SRC_IN);
}
 
Example 4
Source File: RxToast.java    From RxTools-master with Apache License 2.0 4 votes vote down vote up
public static final Drawable tint9PatchDrawableFrame(@NonNull Context context, @ColorInt int tintColor) {
    final NinePatchDrawable toastDrawable = (NinePatchDrawable) getDrawable(context, R.drawable.toast_frame);
    toastDrawable.setColorFilter(new PorterDuffColorFilter(tintColor, PorterDuff.Mode.SRC_IN));
    return toastDrawable;
}
 
Example 5
Source File: ToastyUtils.java    From Bus-Tracking-Parent with GNU General Public License v3.0 4 votes vote down vote up
static Drawable tint9PatchDrawableFrame(@NonNull Context context, @ColorInt int tintColor) {
    final NinePatchDrawable toastDrawable = (NinePatchDrawable) getDrawable(context, R.drawable.toast_frame);
    toastDrawable.setColorFilter(new PorterDuffColorFilter(tintColor, PorterDuff.Mode.SRC_IN));
    return toastDrawable;
}