use of android.graphics.drawable.InsetDrawable in project android_packages_apps_Settings by SudaMod.
the class MusicViewHolderController method setupView.
@Override
public void setupView(AppViewHolder holder) {
holder.appIcon.setImageDrawable(new InsetDrawable(mContext.getDrawable(R.drawable.ic_headset_24dp), INSET_SIZE));
holder.appName.setText(mContext.getText(R.string.audio_files_title));
holder.summary.setText(Formatter.formatFileSize(mContext, mMusicSize));
}
use of android.graphics.drawable.InsetDrawable in project android_packages_apps_Settings by SudaMod.
the class PhotosViewHolderController method setupView.
@Override
public void setupView(AppViewHolder holder) {
holder.appIcon.setImageDrawable(new InsetDrawable(mContext.getDrawable(R.drawable.ic_photo_library), INSET_SIZE));
holder.appName.setText(mContext.getText(R.string.storage_detail_images));
holder.summary.setText(Formatter.formatFileSize(mContext, mFilesSize));
}
use of android.graphics.drawable.InsetDrawable in project platform_packages_apps_Settings by BlissRoms.
the class PhotosViewHolderController method setupView.
@Override
public void setupView(AppViewHolder holder) {
holder.appIcon.setImageDrawable(new InsetDrawable(mContext.getDrawable(R.drawable.ic_photo_library), INSET_SIZE));
holder.appName.setText(mContext.getText(R.string.storage_detail_images));
holder.summary.setText(Formatter.formatFileSize(mContext, mFilesSize));
}
use of android.graphics.drawable.InsetDrawable in project HL4A by HL4A.
the class 绘画 method 生成背景.
public static Drawable 生成背景(Object $普通, Object $按下, Object $圆角) {
if (设备.取SDK() > 21) {
ShapeDrawable $波纹 = new ShapeDrawable();
int $角 = 视图.检查大小($圆角);
float[] $外矩形 = { $角, $角, $角, $角, $角, $角, $角, $角 };
RectF $距离 = new RectF(0, 0, 0, 0);
float[] $内矩形 = { 0, 0, 0, 0, 0, 0, 0, 0 };
RoundRectShape $圆角形状 = new RoundRectShape($外矩形, $距离, $内矩形);
$波纹.setShape($圆角形状);
InsetDrawable $绘画 = new InsetDrawable($波纹, -1);
ShapeDrawable $内容 = new ShapeDrawable();
RoundRectShape $内容形状 = new RoundRectShape($外矩形, $距离, $内矩形);
$内容.setShape($内容形状);
$内容.getPaint().setColor(视图.检查颜色($普通));
$内容.getPaint().setStyle(Paint.Style.FILL);
RippleDrawable $涟漪 = new RippleDrawable(视图.创建单颜色列表($按下), $内容, $绘画);
return $涟漪;
} else {
return new 按下变色绘画($普通, $按下);
}
// return new 涟漪绘画($普通,$按下,颜色.白色);
}
use of android.graphics.drawable.InsetDrawable in project FlatUI by eluleci.
the class FlatToggleButton method init.
private void init(AttributeSet attrs) {
if (attributes == null)
attributes = new Attributes(this, getResources());
if (attrs != null) {
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.fl_FlatToggleButton);
// getting common attributes
int customTheme = a.getResourceId(R.styleable.fl_FlatToggleButton_fl_theme, Attributes.DEFAULT_THEME);
attributes.setThemeSilent(customTheme, getResources());
attributes.setRadius(a.getDimensionPixelSize(R.styleable.fl_FlatToggleButton_fl_cornerRadius, Attributes.DEFAULT_RADIUS_PX));
space = a.getDimensionPixelSize(R.styleable.fl_FlatToggleButton_fl_space, space);
padding = space / 10;
a.recycle();
}
// creating unchecked-enabled state drawable
ShapeDrawable uncheckedEnabledFrontCore = new ShapeDrawable(new RoundRectShape(attributes.getOuterRadius(), null, null));
uncheckedEnabledFrontCore.getPaint().setColor(attributes.getColor(2));
InsetDrawable uncheckedEnabledFront = new InsetDrawable(uncheckedEnabledFrontCore, padding);
ShapeDrawable uncheckedEnabledBack = new ShapeDrawable(new RoundRectShape(attributes.getOuterRadius(), null, null));
uncheckedEnabledBack.getPaint().setColor(Color.parseColor("#f2f2f2"));
uncheckedEnabledBack.setIntrinsicWidth(space / 2 * 5);
uncheckedEnabledBack.setIntrinsicHeight(space);
uncheckedEnabledBack.setPadding(0, 0, space / 2 * 5, 0);
Drawable[] d1 = { uncheckedEnabledBack, uncheckedEnabledFront };
LayerDrawable uncheckedEnabled = new LayerDrawable(d1);
// creating checked-enabled state drawable
ShapeDrawable checkedEnabledFrontCore = new ShapeDrawable(new RoundRectShape(attributes.getOuterRadius(), null, null));
checkedEnabledFrontCore.getPaint().setColor(attributes.getColor(2));
InsetDrawable checkedEnabledFront = new InsetDrawable(checkedEnabledFrontCore, padding);
ShapeDrawable checkedEnabledBack = new ShapeDrawable(new RoundRectShape(attributes.getOuterRadius(), null, null));
checkedEnabledBack.getPaint().setColor(attributes.getColor(3));
checkedEnabledBack.setPadding(space / 2 * 5, 0, 0, 0);
Drawable[] d2 = { checkedEnabledBack, checkedEnabledFront };
LayerDrawable checkedEnabled = new LayerDrawable(d2);
// creating unchecked-disabled state drawable
ShapeDrawable uncheckedDisabledFrontCore = new ShapeDrawable(new RoundRectShape(attributes.getOuterRadius(), null, null));
uncheckedDisabledFrontCore.getPaint().setColor(Color.parseColor("#d2d2d2"));
InsetDrawable uncheckedDisabledFront = new InsetDrawable(uncheckedDisabledFrontCore, padding);
ShapeDrawable uncheckedDisabledBack = new ShapeDrawable(new RoundRectShape(attributes.getOuterRadius(), null, null));
uncheckedDisabledBack.getPaint().setColor(Color.parseColor("#f2f2f2"));
uncheckedDisabledBack.setPadding(0, 0, space / 2 * 5, 0);
Drawable[] d3 = { uncheckedDisabledBack, uncheckedDisabledFront };
LayerDrawable uncheckedDisabled = new LayerDrawable(d3);
// creating checked-disabled state drawable
ShapeDrawable checkedDisabledFrontCore = new ShapeDrawable(new RoundRectShape(attributes.getOuterRadius(), null, null));
checkedDisabledFrontCore.getPaint().setColor(attributes.getColor(3));
InsetDrawable checkedDisabledFront = new InsetDrawable(checkedDisabledFrontCore, padding);
ShapeDrawable checkedDisabledBack = new ShapeDrawable(new RoundRectShape(attributes.getOuterRadius(), null, null));
checkedDisabledBack.getPaint().setColor(Color.parseColor("#f2f2f2"));
checkedDisabledBack.setPadding(space / 2 * 5, 0, 0, 0);
Drawable[] d4 = { checkedDisabledBack, checkedDisabledFront };
LayerDrawable checkedDisabled = new LayerDrawable(d4);
StateListDrawable states = new StateListDrawable();
states.addState(new int[] { -android.R.attr.state_checked, android.R.attr.state_enabled }, new InsetDrawable(uncheckedEnabled, padding * 2));
states.addState(new int[] { android.R.attr.state_checked, android.R.attr.state_enabled }, new InsetDrawable(checkedEnabled, padding * 2));
states.addState(new int[] { -android.R.attr.state_checked, -android.R.attr.state_enabled }, new InsetDrawable(uncheckedDisabled, padding * 2));
states.addState(new int[] { android.R.attr.state_checked, -android.R.attr.state_enabled }, new InsetDrawable(checkedDisabled, padding * 2));
setBackgroundDrawable(states);
setText("");
setTextOff("");
setTextOn("");
setTextSize(0);
}
Aggregations