本文整理了Java中android.widget.Switch.setTrackDrawable()
方法的一些代码示例,展示了Switch.setTrackDrawable()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Switch.setTrackDrawable()
方法的具体详情如下:
包路径:android.widget.Switch
类名称:Switch
方法名:setTrackDrawable
暂无
代码示例来源:origin: lygttpod/SuperTextView
mSwitch.setTrackDrawable(mTrackResource);
代码示例来源:origin: jelic98/dynamico
@Override
public void onDrawableLoaded(Drawable drawable, int requestCode) {
super.onDrawableLoaded(drawable, requestCode);
switch(requestCode) {
case LOAD_THUMB_DRAWABLE:
switchButton.setThumbDrawable(drawable);
break;
case LOAD_TRACK_DRAWABLE:
switchButton.setTrackDrawable(drawable);
break;
}
}
}
代码示例来源:origin: xuancao/DynamicSkin
public static void setTint(@NonNull Switch switchView, @ColorInt int color, boolean useDarker) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) return;
if (switchView.getTrackDrawable() != null) {
switchView.setTrackDrawable(modifySwitchDrawable(switchView.getContext(),
switchView.getTrackDrawable(), color, 0.5f, false, useDarker));
}
if (switchView.getThumbDrawable() != null) {
switchView.setThumbDrawable(modifySwitchDrawable(switchView.getContext(),
switchView.getThumbDrawable(), color, 1.0f, true, useDarker));
}
}
代码示例来源:origin: garretyoder/app-theme-engine
public static void setTint(@NonNull Switch switchView, @ColorInt int color, boolean useDarker) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) return;
if (switchView.getTrackDrawable() != null) {
switchView.setTrackDrawable(modifySwitchDrawable(switchView.getContext(),
switchView.getTrackDrawable(), color, false, false, useDarker));
}
if (switchView.getThumbDrawable() != null) {
switchView.setThumbDrawable(modifySwitchDrawable(switchView.getContext(),
switchView.getThumbDrawable(), color, true, false, useDarker));
}
}
代码示例来源:origin: h4h13/RetroMusicPlayer
public static void setTint(@NonNull Switch switchView, @ColorInt int color, boolean useDarker) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) return;
if (switchView.getTrackDrawable() != null) {
switchView.setTrackDrawable(modifySwitchDrawable(switchView.getContext(),
switchView.getTrackDrawable(), color, false, false, useDarker));
}
if (switchView.getThumbDrawable() != null) {
switchView.setThumbDrawable(modifySwitchDrawable(switchView.getContext(),
switchView.getThumbDrawable(), color, true, false, useDarker));
}
}
代码示例来源:origin: AriesHoo/UIWidget
/**
* 设置Drawable相关属性
*/
private void setSwitchDrawable() {
mSwitch = (Switch) mView;
mStateThumbDrawable = new StateListDrawable();
mStateTrackDrawable = new StateListDrawable();
mStateThumbDrawable.addState(new int[]{mStateChecked}, getStateDrawable(mThumbCheckedDrawable, mThumbRadius, mThumbDrawableWidth, mThumbDrawableHeight, mThumbStrokeWidth, mThumbStrokeCheckedColor));
mStateThumbDrawable.addState(new int[]{mStateSelected}, getStateDrawable(mThumbSelectedDrawable, mThumbRadius, mThumbDrawableWidth, mThumbDrawableHeight, mThumbStrokeWidth, mThumbStrokeSelectedColor));
mStateThumbDrawable.addState(new int[]{mStatePressed}, getStateDrawable(mThumbPressedDrawable, mThumbRadius, mThumbDrawableWidth, mThumbDrawableHeight, mThumbStrokeWidth, mThumbStrokePressedColor));
mStateThumbDrawable.addState(new int[]{mStateDisabled}, getStateDrawable(mThumbDisabledDrawable, mThumbRadius, mThumbDrawableWidth, mThumbDrawableHeight, mThumbStrokeWidth, mThumbStrokeDisabledColor));
mStateThumbDrawable.addState(new int[]{}, getStateDrawable(mThumbDrawable, mThumbRadius, mThumbDrawableWidth, mThumbDrawableHeight, mThumbStrokeWidth, mThumbStrokeColor));
mTrackDrawableHeight = 0;
mStateTrackDrawable.addState(new int[]{mStateChecked}, getStateDrawable(mTrackCheckedDrawable, mTrackRadius, mTrackDrawableWidth, mTrackDrawableHeight, mTrackStrokeWidth, mTrackStrokeCheckedColor));
mStateTrackDrawable.addState(new int[]{mStateSelected}, getStateDrawable(mTrackSelectedDrawable, mTrackRadius, mTrackDrawableWidth, mTrackDrawableHeight, mTrackStrokeWidth, mTrackStrokeSelectedColor));
mStateTrackDrawable.addState(new int[]{mStatePressed}, getStateDrawable(mTrackPressedDrawable, mTrackRadius, mTrackDrawableWidth, mTrackDrawableHeight, mTrackStrokeWidth, mTrackStrokePressedColor));
mStateTrackDrawable.addState(new int[]{mStateDisabled}, getStateDrawable(mTrackDisabledDrawable, mTrackRadius, mTrackDrawableWidth, mTrackDrawableHeight, mTrackStrokeWidth, mTrackStrokeDisabledColor));
mStateTrackDrawable.addState(new int[]{}, getStateDrawable(mTrackDrawable, mTrackRadius, mTrackDrawableWidth, mTrackDrawableHeight, mTrackStrokeWidth, mTrackStrokeColor));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
mSwitch.setThumbDrawable(mStateThumbDrawable);
mSwitch.setTrackDrawable(mStateTrackDrawable);
}
}
内容来源于网络,如有侵权,请联系作者删除!