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


Java Drawable.getMinimumHeight方法代碼示例

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


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

示例1: onMeasure

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		// 創建一個測量規格
		// int measureSpec = MeasureSpec.makeMeasureSpec(100, MeasureSpec.EXACTLY);
		
		// 打印一下父容器傳過來的測量規格
//		System.out.println("父容器傳過來的測量規格");
		MeasureSpecUtil.printMeasureSpec(widthMeasureSpec, heightMeasureSpec);
		
		Drawable drawable = getDrawable();
		
		if (drawable != null) {
			int picWidth = drawable.getMinimumWidth();	// 獲取圖片的寬
			int picHeight = drawable.getMinimumHeight();// 獲取圖片的高
			float scale = (float) picHeight / picWidth;	// 最終要算什麽樣的值,這個值做為被除數
			
			int width = MeasureSpec.getSize(widthMeasureSpec);
			int height = (int) (width * scale);
			heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
		}
		
		super.onMeasure(widthMeasureSpec, heightMeasureSpec);
		
//		System.out.println("ImageView測量出來的自己的寬高為:" + getMeasuredWidth() + " x " + getMeasuredHeight());
	}
 
開發者ID:lwd1815,項目名稱:Selector,代碼行數:26,代碼來源:AutoScaleHeightImageView.java

示例2: drawOverscrollHeader

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
void drawOverscrollHeader(Canvas canvas, Drawable drawable, Rect bounds) {
    final int height = drawable.getMinimumHeight();

    canvas.save();
    canvas.clipRect(bounds);

    final int span = bounds.bottom - bounds.top;
    if (span < height) {
        bounds.top = bounds.bottom - height;
    }

    drawable.setBounds(bounds);
    drawable.draw(canvas);

    canvas.restore();
}
 
開發者ID:Shmilyz,項目名稱:Swap,代碼行數:17,代碼來源:PLA_ListView.java

示例3: drawOverscrollFooter

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
void drawOverscrollFooter(Canvas canvas, Drawable drawable, Rect bounds) {
    final int height = drawable.getMinimumHeight();

    canvas.save();
    canvas.clipRect(bounds);

    final int span = bounds.bottom - bounds.top;
    if (span < height) {
        bounds.bottom = bounds.top + height;
    }

    drawable.setBounds(bounds);
    drawable.draw(canvas);

    canvas.restore();
}
 
開發者ID:Shmilyz,項目名稱:Swap,代碼行數:17,代碼來源:PLA_ListView.java

示例4: onMeasure

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
	 Drawable drawable = getDrawable();
	 if(drawable != null){
		 int width = drawable.getMinimumWidth();
		 int height = drawable.getMinimumHeight();
		 float scale = (float)height/width;
		 
		 int widthMeasure = MeasureSpec.getSize(widthMeasureSpec);
		 int heightMeasure = (int)(widthMeasure*scale);
		 
		 heightMeasureSpec =  MeasureSpec.makeMeasureSpec(heightMeasure, MeasureSpec.EXACTLY);
	 }
	super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
 
開發者ID:popo1379,項目名稱:popomusic,代碼行數:16,代碼來源:AutoScaleHeightImageView.java

示例5: setProgressDrawable

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
 * <p>Define the drawable used to draw the progress bar in
 * progress mode.</p>
 *
 * @param d the new drawable
 *
 * @see #getProgressDrawable()
 * @see #setIndeterminate(boolean)
 */
public void setProgressDrawable(Drawable d) {
    boolean needUpdate;
    if (mProgressDrawable != null && d != mProgressDrawable) {
        mProgressDrawable.setCallback(null);
        needUpdate = true;
    } else {
        needUpdate = false;
    }

    if (d != null) {
        d.setCallback(this);

        // Make sure the ProgressBar is always tall enough
        int drawableHeight = d.getMinimumHeight();
        if (mMaxHeight < drawableHeight) {
            mMaxHeight = drawableHeight;
            requestLayout();
        }
    }
    mProgressDrawable = d;
    if (!mIndeterminate) {
        mCurrentDrawable = d;
        postInvalidate();
    }

    if (needUpdate) {
        updateDrawableBounds(getWidth(), getHeight());
        updateDrawableState();
        doRefreshProgress(android.R.id.progress, mProgress, false, false);
        doRefreshProgress(android.R.id.secondaryProgress, mSecondaryProgress, false, false);
    }
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:42,代碼來源:IcsProgressBar.java

示例6: drawOverscrollHeader

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
void drawOverscrollHeader(Canvas canvas, Drawable drawable, Rect bounds) {
    int height = drawable.getMinimumHeight();
    canvas.save();
    canvas.clipRect(bounds);
    if (bounds.bottom - bounds.top < height) {
        bounds.top = bounds.bottom - height;
    }
    drawable.setBounds(bounds);
    drawable.draw(canvas);
    canvas.restore();
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:12,代碼來源:PLA_ListView.java

示例7: drawOverscrollFooter

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
void drawOverscrollFooter(Canvas canvas, Drawable drawable, Rect bounds) {
    int height = drawable.getMinimumHeight();
    canvas.save();
    canvas.clipRect(bounds);
    if (bounds.bottom - bounds.top < height) {
        bounds.bottom = bounds.top + height;
    }
    drawable.setBounds(bounds);
    drawable.draw(canvas);
    canvas.restore();
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:12,代碼來源:PLA_ListView.java

示例8: getHeight

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@Override
public int getHeight() {
	Drawable drawable = _drawable;
	if (drawable == null) {
		return 0;
	}
	return drawable.getMinimumHeight();
}
 
開發者ID:starcor-company,項目名稱:starcor.xul,代碼行數:9,代碼來源:XulCommonDrawable.java

示例9: createBadgeDrawable

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
private Drawable createBadgeDrawable(Drawable d, int count) {
    if (d == null) return null;

    NumberFormat f = NumberFormat.getIntegerInstance();
    String countStr = count > 99 ? "99+" : f.format(count);

    Bitmap b = Utils.drawableToBitmap(d);
    b = b.copy(Bitmap.Config.ARGB_8888, true);
    Canvas c = new Canvas(b);

    Paint p = new Paint();
    p.setTextAlign(Paint.Align.CENTER);
    p.setColor(Color.WHITE);
    p.setAntiAlias(true);
    p.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10,
            mResources.getDisplayMetrics()));

    Drawable bg = mGbResources.getDrawable(R.drawable.ic_notification_overlay, null);

    final int w = b.getWidth();
    final int h = b.getHeight();
    final Rect r = new Rect();
    p.getTextBounds(countStr, 0, countStr.length(), r);
    final int tw = r.right - r.left;
    final int th = r.bottom - r.top;
    bg.getPadding(r);
    int dw = r.left + tw + r.right;
    if (dw < bg.getMinimumWidth()) {
        dw = bg.getMinimumWidth();
    }
    int x = w-r.right-((dw-r.right-r.left)/2);
    int dh = r.top + th + r.bottom;
    if (dh < bg.getMinimumHeight()) {
        dh = bg.getMinimumHeight();
    }
    if (dw < dh) dw = dh;
    int y = h-r.bottom-((dh-r.top-th-r.bottom)/2);
    bg.setBounds(w-dw, h-dh, w, h);

    bg.draw(c);
    c.drawText(countStr, x, y, p);

    return new BitmapDrawable(mResources, b);
}
 
開發者ID:WrBug,項目名稱:GravityBox,代碼行數:45,代碼來源:LockscreenAppBar.java


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