當前位置: 首頁>>代碼示例>>Java>>正文


Java Drawable.getPadding方法代碼示例

本文整理匯總了Java中android.graphics.drawable.Drawable.getPadding方法的典型用法代碼示例。如果您正苦於以下問題:Java Drawable.getPadding方法的具體用法?Java Drawable.getPadding怎麽用?Java Drawable.getPadding使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.graphics.drawable.Drawable的用法示例。


在下文中一共展示了Drawable.getPadding方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getPadding

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@Override
public boolean getPadding(Rect padding) {
  padding.left = 0;
  padding.top = 0;
  padding.right = 0;
  padding.bottom = 0;
  final Rect rect = mTmpRect;
  for (int i = 0; i < mLayers.length; i++) {
    Drawable drawable = mLayers[i];
    if (drawable != null) {
      drawable.getPadding(rect);
      padding.left = Math.max(padding.left, rect.left);
      padding.top = Math.max(padding.top, rect.top);
      padding.right = Math.max(padding.right, rect.right);
      padding.bottom = Math.max(padding.bottom, rect.bottom);
    }
  }
  return true;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:20,代碼來源:ArrayDrawable.java

示例2: resolvePadding

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
 * Updates value of {@link #mPadding} according to the current specified padding values where
 * also padding of the background's drawable is taken into count.
 */
private void resolvePadding() {
	int paddingLeft = getPaddingLeft();
	int paddingTop = getPaddingTop();
	int paddingRight = getPaddingRight();
	int paddingBottom = getPaddingBottom();
	final Drawable background = getBackground();
	this.ensureRect();
	if (background != null && background.getPadding(mRect)) {
		paddingLeft = Math.max(paddingLeft, mRect.left);
		paddingTop = Math.max(paddingTop, mRect.top);
		paddingRight = Math.max(paddingRight, mRect.right);
		paddingBottom = Math.max(paddingBottom, mRect.bottom);
	}
	this.mPadding = Math.max(paddingLeft, Math.max(paddingTop, Math.max(paddingRight, paddingBottom)));
}
 
開發者ID:universum-studios,項目名稱:android_ui,代碼行數:20,代碼來源:CircularNumberPicker.java

示例3: drawSynthesizedSettingsHintImage

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
private Bitmap drawSynthesizedSettingsHintImage(
        int width, int height, Drawable mainIcon, Drawable hintIcon) {
    if (mainIcon == null || hintIcon == null)
        return null;
    Rect hintIconPadding = new Rect(0, 0, 0, 0);
    hintIcon.getPadding(hintIconPadding);
    final Bitmap buffer = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    final Canvas canvas = new Canvas(buffer);
    canvas.drawColor(mRes.getColor(R.color.latinkeyboard_transparent), PorterDuff.Mode.CLEAR);

    // Draw main icon at the center of the key visual
    // Assuming the hintIcon shares the same padding with the key's background drawable
    final int drawableX = (width + hintIconPadding.left - hintIconPadding.right
            - mainIcon.getIntrinsicWidth()) / 2;
    final int drawableY = (height + hintIconPadding.top - hintIconPadding.bottom
            - mainIcon.getIntrinsicHeight()) / 2;
    setDefaultBounds(mainIcon);
    canvas.translate(drawableX, drawableY);
    mainIcon.draw(canvas);
    canvas.translate(-drawableX, -drawableY);

    // Draw hint icon fully in the key
    hintIcon.setBounds(0, 0, width, height);
    hintIcon.draw(canvas);
    return buffer;
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:27,代碼來源:LatinKeyboard.java

示例4: setForeground

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
 * Supply a Drawable that is to be rendered on top of all of the child
 * views in the frame layout.  Any padding in the Drawable will be taken
 * into account by ensuring that the children are inset to be placed
 * inside of the padding area.
 *
 * @param drawable The Drawable to be drawn on top of the children.
 */
public void setForeground(View view, Drawable drawable) {
    if (view != null) {
        if (mForeground != drawable) {
            if (mForeground != null) {
                mForeground.setCallback(null);
                view.unscheduleDrawable(mForeground);
            }

            mForeground = drawable;

            if (drawable != null) {
                view.setWillNotDraw(false);
                drawable.setCallback(view);
                if (drawable.isStateful()) {
                    drawable.setState(view.getDrawableState());
                }
                if (mForegroundGravity == Gravity.FILL) {
                    Rect padding = new Rect();
                    drawable.getPadding(padding);
                }

                //update bounds
                updateBounds(view, drawable);//added by song
            } else {
                view.setWillNotDraw(true);
            }
            view.requestLayout();
            view.invalidate();
        }
    }
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:40,代碼來源:ForegroundDelegate.java

示例5: setTextAndScaleX

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
private void setTextAndScaleX(final String text) {
    setTextScaleX(1.0f);
    setText(text);
    if (sNoScaleXTextSet.contains(text)) {
        return;
    }
    // TODO: Override {@link #setBackground(Drawable)} that is supported from API 16 and
    // calculate maximum text width.
    final Drawable background = getBackground();
    if (background == null) {
        return;
    }
    background.getPadding(mBackgroundPadding);
    final int maxWidth = background.getIntrinsicWidth() - mBackgroundPadding.left
            - mBackgroundPadding.right;
    final float width = getTextWidth(text, getPaint());
    if (width <= maxWidth) {
        sNoScaleXTextSet.add(text);
        return;
    }
    setTextScaleX(maxWidth / width);
}
 
開發者ID:rkkr,項目名稱:simple-keyboard,代碼行數:23,代碼來源:KeyPreviewView.java

示例6: setBackground

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
 * Set the background to a given Drawable, or remove the background.
 *
 * @param background the Drawable to use as the background, or null to remove the background.
 */
@SuppressWarnings("deprecation")
// View#setBackgroundDrawable is compatible with pre-API level 16 (Jelly Bean).
public void setBackground(Drawable background) {
  mContainer.setBackgroundDrawable(background);

  // Force setting of padding.
  // setBackgroundDrawable does not call setPadding if the background has 0 padding.
  if (background != null) {
    Rect rect = new Rect();
    background.getPadding(rect);
    mContainer.setPadding(rect.left, rect.top, rect.right, rect.bottom);
  } else {
    mContainer.setPadding(0, 0, 0, 0);
  }
}
 
開發者ID:mapbox,項目名稱:mapbox-plugins-android,代碼行數:21,代碼來源:IconGenerator.java

示例7: initIndicatorRect

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
 * The size of the indicator is same as the content region of the {@link #mBgDrawable} minus
 * half the stroke size to accommodate the indicator.
 */
private void initIndicatorRect() {
    Drawable d = mBgDrawable;
    Rect bounds = d.getBounds();

    d.getPadding(sTempRect);
    // Amount by which padding has to be scaled
    float paddingScaleX = ((float) bounds.width()) / d.getIntrinsicWidth();
    float paddingScaleY = ((float) bounds.height()) / d.getIntrinsicHeight();
    mIndicatorRect.set(
            bounds.left + sTempRect.left * paddingScaleX,
            bounds.top + sTempRect.top * paddingScaleY,
            bounds.right - sTempRect.right * paddingScaleX,
            bounds.bottom - sTempRect.bottom * paddingScaleY);

    float inset = mPaint.getStrokeWidth() / 2;
    mIndicatorRect.inset(inset, inset);
    mIndicatorRectDirty = false;
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:23,代碼來源:PreloadIconDrawable.java

示例8: onDrawShadow

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
 * 繪製外部陰影.
 */
public void onDrawShadow(Canvas canvas)
{
    Drawable drawableShadow = getShadowDrawable();
    if (drawableShadow != null)
    {
        Rect shadowPaddingRect = getDrawShadowRect();
        int width = getMainUpView().getWidth();
        int height = getMainUpView().getHeight();
        Rect padding = new Rect();
        drawableShadow.getPadding(padding);
        drawableShadow.setBounds(-padding.left - (shadowPaddingRect.left),
            -padding.top - (shadowPaddingRect.top),
            width + padding.right + (shadowPaddingRect.right),
            height + padding.bottom + (shadowPaddingRect.bottom));
        drawableShadow.draw(canvas);
    }
}
 
開發者ID:Dreamxiaoxuan,項目名稱:AndroidTvDemo,代碼行數:21,代碼來源:BaseEffectBridgeWrapper.java

示例9: onDrawUpRect

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
 * 繪製最上層的移動邊框.
 */
public void onDrawUpRect(Canvas canvas)
{
    Drawable drawableUp = getUpRectDrawable();
    if (drawableUp != null)
    {
        Rect paddingRect = getDrawUpRect();
        int width = getMainUpView().getWidth();
        int height = getMainUpView().getHeight();
        Rect padding = new Rect();
        // 邊框的繪製.
        drawableUp.getPadding(padding);
        drawableUp.setBounds(-padding.left - (paddingRect.left),
            -padding.top - (paddingRect.top),
            width + padding.right + (paddingRect.right),
            height + padding.bottom + (paddingRect.bottom));
        drawableUp.draw(canvas);
    }
}
 
開發者ID:Dreamxiaoxuan,項目名稱:AndroidTvDemo,代碼行數:22,代碼來源:BaseEffectBridgeWrapper.java

示例10: setSelectionIndicator

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
 * Sets the drawable used to draw the number selection indicator.
 *
 * @param indicator The desired drawable for selection indicator. May be {@code null} to clear
 *                  the current one.
 * @see R.attr#uiSelectionIndicator ui:uiSelectionIndicator
 * @see #setSelectionIndicatorTintList(ColorStateList)
 * @see #setSelectionIndicatorTintMode(PorterDuff.Mode)
 * @see #getSelectionIndicator()
 */
public void setSelectionIndicator(@Nullable Drawable indicator) {
	if (mSelectionIndicator != indicator) {
		final boolean needUpdate;
		if (mSelectionIndicator != null) {
			mSelectionIndicator.setCallback(null);
			unscheduleDrawable(mSelectionIndicator);
			needUpdate = true;
		} else {
			needUpdate = false;
		}

		if (indicator != null) {
			indicator.setCallback(this);
			indicator.setVisible(getVisibility() == VISIBLE, false);
			if (indicator.getPadding(mRect)) {
				TEXT_INFO.padding = Math.max(mRect.left, Math.max(mRect.top, Math.max(mRect.right, mRect.bottom)));
			}
		} else {
			this.mSelectionIndicatorRes = 0;
		}
		this.mSelectionIndicator = indicator;
		this.applySelectionIndicatorTint();
		if (needUpdate) {
			if (mSelectionIndicator.isStateful()) {
				mSelectionIndicator.setState(getDrawableState());
			}
			this.invalidateNumbersArea();
		}
	}
}
 
開發者ID:universum-studios,項目名稱:android_ui,代碼行數:41,代碼來源:CircularNumberPicker.java

示例11: setSelector

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
public void setSelector(Drawable sel) {
    if (mSelector != null) {
        mSelector.setCallback(null);
        unscheduleDrawable(mSelector);
    }
    mSelector = sel;
    Rect padding = new Rect();
    sel.getPadding(padding);
    mSelectionLeftPadding = padding.left;
    mSelectionTopPadding = padding.top;
    mSelectionRightPadding = padding.right;
    mSelectionBottomPadding = padding.bottom;
    sel.setCallback(this);
    sel.setState(getDrawableState());
}
 
開發者ID:Shmilyz,項目名稱:Swap,代碼行數:16,代碼來源:PLA_AbsListView.java

示例12: computeContentWidth

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
void computeContentWidth() {
    Drawable background = getBackground();
    int hOffset = 0;
    if (background != null) {
        background.getPadding(AppCompatSpinner.this.mTempRect);
        hOffset = ViewUtils.isLayoutRtl(AppCompatSpinner.this) ? AppCompatSpinner.this.mTempRect.right : -AppCompatSpinner.this.mTempRect.left;
    } else {
        Rect access$300 = AppCompatSpinner.this.mTempRect;
        AppCompatSpinner.this.mTempRect.right = 0;
        access$300.left = 0;
    }
    int spinnerPaddingLeft = AppCompatSpinner.this.getPaddingLeft();
    int spinnerPaddingRight = AppCompatSpinner.this.getPaddingRight();
    int spinnerWidth = AppCompatSpinner.this.getWidth();
    if (AppCompatSpinner.this.mDropDownWidth == -2) {
        int contentWidth = AppCompatSpinner.this.compatMeasureContentWidth((SpinnerAdapter) this.mAdapter, getBackground());
        int contentWidthLimit = (AppCompatSpinner.this.getContext().getResources().getDisplayMetrics().widthPixels - AppCompatSpinner.this.mTempRect.left) - AppCompatSpinner.this.mTempRect.right;
        if (contentWidth > contentWidthLimit) {
            contentWidth = contentWidthLimit;
        }
        setContentWidth(Math.max(contentWidth, (spinnerWidth - spinnerPaddingLeft) - spinnerPaddingRight));
    } else if (AppCompatSpinner.this.mDropDownWidth == -1) {
        setContentWidth((spinnerWidth - spinnerPaddingLeft) - spinnerPaddingRight);
    } else {
        setContentWidth(AppCompatSpinner.this.mDropDownWidth);
    }
    if (ViewUtils.isLayoutRtl(AppCompatSpinner.this)) {
        hOffset += (spinnerWidth - spinnerPaddingRight) - getWidth();
    } else {
        hOffset += spinnerPaddingLeft;
    }
    setHorizontalOffset(hOffset);
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:34,代碼來源:AppCompatSpinner.java

示例13: setSelector

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
public void setSelector(Drawable sel) {
    if (this.mSelector != null) {
        this.mSelector.setCallback(null);
        unscheduleDrawable(this.mSelector);
    }
    this.mSelector = sel;
    Rect padding = new Rect();
    sel.getPadding(padding);
    this.mSelectionLeftPadding = padding.left;
    this.mSelectionTopPadding = padding.top;
    this.mSelectionRightPadding = padding.right;
    this.mSelectionBottomPadding = padding.bottom;
    sel.setCallback(this);
    updateSelectorState();
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:16,代碼來源:AbsHListView.java

示例14: setSelector

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
public void setSelector(Drawable sel) {
	if (mSelector != null) {
		mSelector.setCallback(null);
		unscheduleDrawable(mSelector);
	}
	mSelector = sel;
	Rect padding = new Rect();
	sel.getPadding(padding);
	mSelectionLeftPadding = padding.left;
	mSelectionTopPadding = padding.top;
	mSelectionRightPadding = padding.right;
	mSelectionBottomPadding = padding.bottom;
	sel.setCallback(this);
	updateSelectorState();
}
 
開發者ID:junchenChow,項目名稱:exciting-app,代碼行數:16,代碼來源:AbsHListView.java

示例15: setForeground

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
 * Supply a Drawable that is to be rendered on top of all of the child
 * views in the frame layout.  Any padding in the Drawable will be taken
 * into account by ensuring that the children are inset to be placed
 * inside of the padding area.
 *
 * @param drawable The Drawable to be drawn on top of the children.
 */
public void setForeground(Drawable drawable) {
    if (mForeground != drawable) {
        if (mForeground != null) {
            mForeground.setCallback(null);
            unscheduleDrawable(mForeground);
        }

        mForeground = drawable;

        if (drawable != null) {
            setWillNotDraw(false);
            drawable.setCallback(this);
            if (drawable.isStateful()) {
                drawable.setState(getDrawableState());
            }
            if (mForegroundGravity == Gravity.FILL) {
                Rect padding = new Rect();
                drawable.getPadding(padding);
            }
        }  else {
            setWillNotDraw(true);
        }
        requestLayout();
        invalidate();
    }
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:35,代碼來源:ForegroundLinearLayout.java


注:本文中的android.graphics.drawable.Drawable.getPadding方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。