本文整理汇总了Java中android.graphics.drawable.ShapeDrawable.setPadding方法的典型用法代码示例。如果您正苦于以下问题:Java ShapeDrawable.setPadding方法的具体用法?Java ShapeDrawable.setPadding怎么用?Java ShapeDrawable.setPadding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.drawable.ShapeDrawable
的用法示例。
在下文中一共展示了ShapeDrawable.setPadding方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDefaultOverButtonBgDrawable
import android.graphics.drawable.ShapeDrawable; //导入方法依赖的package包/类
private StateListDrawable createDefaultOverButtonBgDrawable() {
int dp12 = (int) ThemeUtils.applyDimensionDp(this, 12.f);
int dp8 = (int) ThemeUtils.applyDimensionDp(this, 8.f);
float dp4 = ThemeUtils.applyDimensionDp(this, 4.f);
float[] round = new float[]{dp4, dp4, dp4, dp4, dp4, dp4, dp4, dp4};
ShapeDrawable pressedDrawable = new ShapeDrawable(new RoundRectShape(round, null, null));
pressedDrawable.setPadding(dp12, dp8, dp12, dp8);
int pressedColor = ThemeUtils.resolveColor(this, R.attr.gallery_toolbar_over_button_pressed_color, R.color.gallery_default_toolbar_over_button_pressed_color);
pressedDrawable.getPaint().setColor(pressedColor);
int normalColor = ThemeUtils.resolveColor(this, R.attr.gallery_toolbar_over_button_normal_color, R.color.gallery_default_toolbar_over_button_normal_color);
ShapeDrawable normalDrawable = new ShapeDrawable(new RoundRectShape(round, null, null));
normalDrawable.setPadding(dp12, dp8, dp12, dp8);
normalDrawable.getPaint().setColor(normalColor);
StateListDrawable stateListDrawable = new StateListDrawable();
stateListDrawable.addState(new int[]{android.R.attr.state_pressed}, pressedDrawable);
stateListDrawable.addState(new int[]{}, normalDrawable);
return stateListDrawable;
}
示例2: buildColorPickerView
import android.graphics.drawable.ShapeDrawable; //导入方法依赖的package包/类
private void buildColorPickerView(View view, int colorCode) {
view.setVisibility(View.VISIBLE);
ShapeDrawable biggerCircle = new ShapeDrawable(new OvalShape());
biggerCircle.setIntrinsicHeight(20);
biggerCircle.setIntrinsicWidth(20);
biggerCircle.setBounds(new Rect(0, 0, 20, 20));
biggerCircle.getPaint().setColor(colorCode);
ShapeDrawable smallerCircle = new ShapeDrawable(new OvalShape());
smallerCircle.setIntrinsicHeight(5);
smallerCircle.setIntrinsicWidth(5);
smallerCircle.setBounds(new Rect(0, 0, 5, 5));
smallerCircle.getPaint().setColor(Color.WHITE);
smallerCircle.setPadding(10, 10, 10, 10);
Drawable[] drawables = {smallerCircle, biggerCircle};
LayerDrawable layerDrawable = new LayerDrawable(drawables);
view.setBackgroundDrawable(layerDrawable);
}
示例3: change
import android.graphics.drawable.ShapeDrawable; //导入方法依赖的package包/类
private void change() {
float[] outerR = new float[]{mSize / 2, mSize / 2, mSize / 2, mSize / 2, mSize / 2, mSize / 2, mSize / 2, mSize / 2};
Shape shape = new RoundRectShape(outerR, null, null);
ShapeDrawable shapeDrawable = new ShapeDrawable(shape);
shapeDrawable.setIntrinsicHeight((int) mSize);
shapeDrawable.setIntrinsicWidth((int) mSize);
shapeDrawable.setPadding(0, 0, 0, 0);
shapeDrawable.getPaint().setColor(mColor);
shapeDrawable.getPaint().setStyle(Paint.Style.FILL);
setBackgroundDrawable(shapeDrawable);
setHeight((int) mSize);
setMinWidth((int) mSize);
}