Java Code Examples for android.graphics.drawable.NinePatchDrawable#getPadding()
The following examples show how to use
android.graphics.drawable.NinePatchDrawable#getPadding() .
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: ForegroundRelativeLayout.java From Android-nRF-Toolbox with BSD 3-Clause "New" or "Revised" License | 6 votes |
public ForegroundRelativeLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ForegroundRelativeLayout, defStyle, 0); final Drawable d = a.getDrawable(R.styleable.ForegroundRelativeLayout_foreground); if (d != null) { setForeground(d); } a.recycle(); if (this.getBackground() instanceof NinePatchDrawable) { final NinePatchDrawable npd = (NinePatchDrawable) this.getBackground(); rectPadding = new Rect(); if (npd.getPadding(rectPadding)) { useBackgroundPadding = true; } } }
Example 2
Source File: ForegroundLinearLayout.java From Android-nRF-Toolbox with BSD 3-Clause "New" or "Revised" License | 6 votes |
public ForegroundLinearLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ForegroundLinearLayout, defStyle, 0); final Drawable d = a.getDrawable(R.styleable.ForegroundRelativeLayout_foreground); if (d != null) { setForeground(d); } a.recycle(); if (this.getBackground() instanceof NinePatchDrawable) { final NinePatchDrawable npd = (NinePatchDrawable) this.getBackground(); rectPadding = new Rect(); if (npd.getPadding(rectPadding)) { useBackgroundPadding = true; } } }
Example 3
Source File: MaterialShadowContainerView.java From android-materialshadowninepatch with Apache License 2.0 | 5 votes |
private void updateNinePatchBounds(NinePatchDrawable ninePatch, int childLeft, int childTop, int childRight, int childBottom) { if (ninePatch == null) { return; } final Rect t = mTempRect; ninePatch.getPadding(t); ninePatch.setBounds( childLeft - t.left, childTop - t.top, childRight + t.right, childBottom + t.bottom); }
Example 4
Source File: ForegroundImageView.java From ForegroundViews with Apache License 2.0 | 5 votes |
public ForegroundImageView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ForegroundLayout, defStyle, 0); final Drawable d = a.getDrawable(R.styleable.ForegroundLayout_foreground); foregroundPadding = a.getBoolean(R.styleable.ForegroundLayout_foregroundInsidePadding, false); backgroundAsForeground = a.getBoolean(R.styleable.ForegroundLayout_backgroundAsForeground, false); // Apply foreground padding for ninepatches automatically if (!foregroundPadding && getBackground() instanceof NinePatchDrawable) { final NinePatchDrawable npd = (NinePatchDrawable) getBackground(); if (npd != null && npd.getPadding(rectPadding)) { foregroundPadding = true; } } final Drawable b = getBackground(); if (backgroundAsForeground && b != null) { setForeground(b); } else if (d != null) { setForeground(d); } a.recycle(); }
Example 5
Source File: ForegroundRelativeLayout.java From ForegroundViews with Apache License 2.0 | 5 votes |
public ForegroundRelativeLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ForegroundLayout, defStyle, 0); final Drawable d = a.getDrawable(R.styleable.ForegroundLayout_foreground); foregroundPadding = a.getBoolean(R.styleable.ForegroundLayout_foregroundInsidePadding, false); backgroundAsForeground = a.getBoolean(R.styleable.ForegroundLayout_backgroundAsForeground, false); // Apply foreground padding for ninepatches automatically if (!foregroundPadding && getBackground() instanceof NinePatchDrawable) { final NinePatchDrawable npd = (NinePatchDrawable) getBackground(); if (npd != null && npd.getPadding(rectPadding)) { foregroundPadding = true; } } final Drawable b = getBackground(); if (backgroundAsForeground && b != null) { setForeground(b); } else if (d != null) { setForeground(d); } a.recycle(); }
Example 6
Source File: ForegroundTextView.java From ForegroundViews with Apache License 2.0 | 5 votes |
public ForegroundTextView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ForegroundLayout, defStyle, 0); final Drawable d = a.getDrawable(R.styleable.ForegroundLayout_foreground); foregroundPadding = a.getBoolean(R.styleable.ForegroundLayout_foregroundInsidePadding, false); backgroundAsForeground = a.getBoolean(R.styleable.ForegroundLayout_backgroundAsForeground, false); // Apply foreground padding for ninepatches automatically if (!foregroundPadding && getBackground() instanceof NinePatchDrawable) { final NinePatchDrawable npd = (NinePatchDrawable) getBackground(); if (npd != null && npd.getPadding(rectPadding)) { foregroundPadding = true; } } final Drawable b = getBackground(); if (backgroundAsForeground && b != null) { setForeground(b); } else if (d != null) { setForeground(d); } a.recycle(); }
Example 7
Source File: ForegroundLinearLayout.java From ForegroundViews with Apache License 2.0 | 5 votes |
public ForegroundLinearLayout(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ForegroundLayout, defStyle, 0); final Drawable d = a.getDrawable(R.styleable.ForegroundLayout_foreground); foregroundPadding = a.getBoolean(R.styleable.ForegroundLayout_foregroundInsidePadding, false); backgroundAsForeground = a.getBoolean(R.styleable.ForegroundLayout_backgroundAsForeground, false); // Apply foreground padding for ninepatches automatically if (!foregroundPadding && getBackground() instanceof NinePatchDrawable) { final NinePatchDrawable npd = (NinePatchDrawable) getBackground(); if (npd != null && npd.getPadding(rectPadding)) { foregroundPadding = true; } } final Drawable b = getBackground(); if (backgroundAsForeground && b != null) { setForeground(b); } else if (d != null) { setForeground(d); } a.recycle(); }