Java Code Examples for androidx.appcompat.widget.SwitchCompat#setTrackDrawable()

The following examples show how to use androidx.appcompat.widget.SwitchCompat#setTrackDrawable() . 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: TintHelper.java    From a with GNU General Public License v3.0 5 votes vote down vote up
public static void setTint(@NonNull SwitchCompat switchView, @ColorInt int color, boolean useDarker) {
    if (switchView.getTrackDrawable() != null) {
        switchView.setTrackDrawable(modifySwitchDrawable(switchView.getContext(),
                switchView.getTrackDrawable(), color, false, true, useDarker));
    }
    if (switchView.getThumbDrawable() != null) {
        switchView.setThumbDrawable(modifySwitchDrawable(switchView.getContext(),
                switchView.getThumbDrawable(), color, true, true, useDarker));
    }
}
 
Example 2
Source File: TintHelper.java    From MyBookshelf with GNU General Public License v3.0 5 votes vote down vote up
public static void setTint(@NonNull SwitchCompat switchView, @ColorInt int color, boolean useDarker) {
    if (switchView.getTrackDrawable() != null) {
        switchView.setTrackDrawable(modifySwitchDrawable(switchView.getContext(),
                switchView.getTrackDrawable(), color, false, true, useDarker));
    }
    if (switchView.getThumbDrawable() != null) {
        switchView.setThumbDrawable(modifySwitchDrawable(switchView.getContext(),
                switchView.getThumbDrawable(), color, true, true, useDarker));
    }
}