編輯:關於Android編程
mode共有三種情況,取值分別為
MeasureSpec.UNSPECIFIED,MeasureSpec.EXACTLY,MeasureSpec.AT_MOST。
以下是框架中View的onMeasure的典型實現:
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int measuredHeight = measureHeight(heightMeasureSpec);
int measuredWidth = measureWidth(widthMeasureSpec);
setMeasuredDimension(measuredHeight, measuredWidth);
}
private int measureHeight(int measureSpec) {
int specMode = MeasureSpec.getMode(measureSpec);
int specSize = MeasureSpec.getSize(measureSpec);
// Default size if no limits are specified.
int result = 500;
if (specMode == MeasureSpec.AT_MOST) {
// Calculate the ideal size of your
// control within this maximum size.
// If your control fills the available
// space return the outer bound.
result = specSize;
} else if (specMode == MeasureSpec.EXACTLY) {
// If your control can fit within these bounds return that
// value.
result = specSize;
}
return result;
}
private int measureWidth(int measureSpec) {
int specMode = MeasureSpec.getMode(measureSpec);
int specSize = MeasureSpec.getSize(measureSpec);
// Default size if no limits are specified.
int result = 500;
if (specMode == MeasureSpec.AT_MOST) {
// Calculate the ideal size of your control
// within this maximum size.
// If your control fills the available space
// return the outer bound.
result = specSize;
}
else if (specMode == MeasureSpec.EXACTLY) {
// If your control can fit within these bounds return that
// value.
result = specSize;
}
return result;
}
微信下拉沒有小視頻了怎麼辦
細心的小伙伴可能都現了微信下拉沒有小視頻功能只顯示微信圖標,最新版本的微信下拉不能拍小視頻啦,這是什麼原因呢?如果你還在疑惑微信下拉小視頻怎麼沒有了這個問題
android Setting中隱藏項實現原理與代碼
我們都知道做程序員有時會惡搞,就像android中,程序員在setting中就隱藏這樣一項:我們可以找到“關於手機這一項在裡面有“android版本”這一項,如圖:當我們
Android代碼混淆ProGuard工作原理簡介
ProGuard能夠對Java類中的代碼進行壓縮(Shrink),優化(Optimize),混淆(Obfuscate),預檢(Preveirfy)。 1. 壓縮(Sh
Android之旅十七 android中的廣播使用
廣播是一種廣泛運用在應用程序之間傳輸信息的機制,android中的廣播用於監聽系統事件或應用程序事件!android中的廣播包括普通廣播、有序廣播以及異步廣播(粘性廣播)