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


Java Drawable.getMinimumWidth方法代碼示例

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


在下文中一共展示了Drawable.getMinimumWidth方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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 width = drawable.getMinimumWidth();

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

	final int span = bounds.right - bounds.left;
	if (span < width) {
		bounds.left = bounds.right - width;
	}

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

	canvas.restore();
}
 
開發者ID:junchenChow,項目名稱:exciting-app,代碼行數:17,代碼來源:HListView.java

示例3: drawOverscrollFooter

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

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

	final int span = bounds.right - bounds.left;
	if (span < width) {
		bounds.right = bounds.left + width;
	}

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

	canvas.restore();
}
 
開發者ID:junchenChow,項目名稱:exciting-app,代碼行數:17,代碼來源:HListView.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: drawOverscrollHeader

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

示例6: drawOverscrollFooter

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

示例7: setHeaderIcon

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
private void setHeaderIcon(ContextMenu menu, Drawable icon) {
    int width = getHeaderIconWidth();
    if (icon.getMinimumWidth() <= width) {
        menu.setHeaderIcon(icon);
    } else if (icon instanceof BitmapDrawable) {
        Bitmap bitmap = Bitmap.createScaledBitmap(((BitmapDrawable) icon).getBitmap(), width, width, false);
        menu.setHeaderIcon(new BitmapDrawable(getResources(), bitmap));
    }
}
 
開發者ID:brevent,項目名稱:prevent,代碼行數:10,代碼來源:PreventFragment.java

示例8: cropDrawable

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
private Drawable cropDrawable(Drawable icon) {
    int width = getPixel(0x20);
    if (icon.getMinimumWidth() > width && icon instanceof BitmapDrawable) {
        Bitmap bitmap = Bitmap.createScaledBitmap(((BitmapDrawable) icon).getBitmap(), width, width, false);
        return new BitmapDrawable(getResources(), bitmap);
    }
    return icon;
}
 
開發者ID:brevent,項目名稱:prevent,代碼行數:9,代碼來源:UserGuideActivity.java

示例9: getWidth

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

示例10: drawLens

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
protected void drawLens(Canvas g, Drawable image, final int w, final int h) {
	final int iw = image.getMinimumWidth();
	drawImage(g, image, w / 2 - iw / 2, 5, iw, h - 5);
}
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:5,代碼來源:Rays.java

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