View.OnMeasure(Int32, Int32) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
測量檢視及其內容,以判斷測量的寬度和測量的高度。
[Android.Runtime.Register("onMeasure", "(II)V", "GetOnMeasure_IIHandler")]
protected virtual void OnMeasure(int widthMeasureSpec, int heightMeasureSpec);
[<Android.Runtime.Register("onMeasure", "(II)V", "GetOnMeasure_IIHandler")>]
abstract member OnMeasure : int * int -> unit
override this.OnMeasure : int * int -> unit
參數
- widthMeasureSpec
- Int32
由母方施加的水平空間需求。
需求以 編碼。android.view.View.MeasureSpec
- heightMeasureSpec
- Int32
由父方施加的垂直空間需求。
需求以 編碼。android.view.View.MeasureSpec
- 屬性
備註
測量檢視及其內容,以判斷測量的寬度和測量的高度。 此方法被子類別調用 #measure(int, int) ,並應被覆蓋,以提供準確且高效的內容測量。
<強>CONTRACT:</strong> 在覆寫此方法時,你<>必須</em> 呼叫#setMeasuredDimension(int, int)來儲存此視圖的測量寬度與高度。 若未如此,將觸發 IllegalStateException, #measure(int, int)由 擲出。 呼叫超類別」 #onMeasure(int, int) 是一個合理的用法。
度量的基底類別實作預設為背景大小,除非 MeasureSpec 允許更大大小。 子職業應該被覆蓋 #onMeasure(int, int) ,以更好地衡量其內容。
若此方法被覆寫,子類別負責確保測量的高度與寬度至少為視圖的最小高度與寬度(#getSuggestedMinimumHeight() 且 #getSuggestedMinimumWidth())。
的 android.view.View.onMeasure(int, int)Java 檔。
此頁面的部分是根據 Android 開放原始碼專案所建立和共用的工作進行修改,並根據 Creative Commons 2.5 屬性授權中所述的詞彙使用。
適用於
另請參閱
- MeasuredWidth
- MeasuredHeight
- <xref:Android.Views.View.SetMeasuredDimension(System.Int32%2c+System.Int32)>
- SuggestedMinimumHeight
- SuggestedMinimumWidth