本文整理匯總了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);
}