AbsoluteLayout 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將子項目放在絕對位置。
public ref class AbsoluteLayout : Microsoft::Maui::Controls::Layout, Microsoft::Maui::IAbsoluteLayout, System::Collections::Generic::ICollection<Microsoft::Maui::IView ^>, System::Collections::Generic::IEnumerable<Microsoft::Maui::IView ^>, System::Collections::Generic::IList<Microsoft::Maui::IView ^>
public class AbsoluteLayout : Microsoft.Maui.Controls.Layout, Microsoft.Maui.IAbsoluteLayout, System.Collections.Generic.ICollection<Microsoft.Maui.IView>, System.Collections.Generic.IEnumerable<Microsoft.Maui.IView>, System.Collections.Generic.IList<Microsoft.Maui.IView>
type AbsoluteLayout = class
inherit Layout
interface IAbsoluteLayout
interface ILayout
interface IView
interface IElement
interface ITransform
interface IContainer
interface IList<IView>
interface ICollection<IView>
interface seq<IView>
interface IEnumerable
interface ISafeAreaView
interface IPadding
type AbsoluteLayout = class
inherit Layout
interface IAbsoluteLayout
interface ILayout
interface IView
interface IElement
interface ITransform
interface IContainer
interface IList<IView>
interface ICollection<IView>
interface seq<IView>
interface IEnumerable
interface ISafeAreaView
interface IPadding
interface ICrossPlatformLayout
Public Class AbsoluteLayout
Inherits Layout
Implements IAbsoluteLayout, ICollection(Of IView), IEnumerable(Of IView), IList(Of IView)
- 繼承
- 實作
備註
應用程式開發人員可以根據傳遞至 SetLayoutFlags(BindableObject, AbsoluteLayoutFlags) 方法的值,提供比例座標、裝置座標或兩者的組合,AbsoluteLayoutFlags來控制子元素的位置。 提供其中一個比例 AbsoluteLayoutFlags 列舉值時,介於 0.0 和 1.0 之間的對應 X 或 Y 自變數一律會導致子系完全顯示在螢幕上。 也就是說,您不需要減去或新增子系的高度或寬度,即可以的左、右、上或底 AbsoluteLayout端顯示。 若為未按比例指定寬度、高度、X 或 Y 值,應用程式開發人員會使用裝置相依單位來尋找及調整子元素的大小。
下列範例示範如何搭配比例位置自變數使用 AbsoluteLayout 。
Label header = new Label
{
Text = "AbsoluteLayout Demo",
FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
HorizontalOptions = LayoutOptions.Center
};
AbsoluteLayout simpleLayout = new AbsoluteLayout
{
BackgroundColor = Color.Blue.WithLuminosity(0.9),
VerticalOptions = LayoutOptions.FillAndExpand
};
topLeftLabel = new Label
{
Text = "Top Left",
TextColor = Color.Black
};
centerLabel = new Label
{
Text = "Centered",
TextColor = Color.Black
};
bottomRightLabel = new Label
{
Text = "Bottom Right",
TextColor = Color.Black
};
// PositionProportional flag maps the range (0.0, 1.0) to
// the range "flush [left|top]" to "flush [right|bottom]"
AbsoluteLayout.SetLayoutFlags(bottomRightLabel,
AbsoluteLayoutFlags.PositionProportional);
AbsoluteLayout.SetLayoutBounds(topLeftLabel,
new Rectangle(0f,
0f, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));
AbsoluteLayout.SetLayoutFlags(centerLabel,
AbsoluteLayoutFlags.PositionProportional);
AbsoluteLayout.SetLayoutBounds(centerLabel,
new Rectangle(0.5,
0.5, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));
AbsoluteLayout.SetLayoutFlags(bottomRightLabel,
AbsoluteLayoutFlags.PositionProportional);
AbsoluteLayout.SetLayoutBounds(bottomRightLabel,
new Rectangle(1f,
1f, AbsoluteLayout.AutoSize, AbsoluteLayout.AutoSize));
simpleLayout.Children.Add(topLeftLabel);
simpleLayout.Children.Add(centerLabel);
simpleLayout.Children.Add(bottomRightLabel);
下列程式代碼範例示範如何藉由指定裝置相依單位來放置兩個標籤。
AbsoluteLayout simpleLayout = new AbsoluteLayout
{
BackgroundColor = Color.Blue.WithLuminosity(0.9),
VerticalOptions = LayoutOptions.FillAndExpand
};
Label header = new Label
{
Text = "Device Units Demo",
TextColor = Color.Black,
FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label))
};
topLeftText = new Label
{
Text = "Left",
TextColor = Color.Black
};
AbsoluteLayout.SetLayoutFlags(topLeftText,
AbsoluteLayoutFlags.None);
AbsoluteLayout.SetLayoutBounds(topLeftText,
new Rectangle(0f, 0f, 100f, 50f));
middleText = new Label
{
Text = "Device-dependent location",
TextColor = Color.Black
};
AbsoluteLayout.SetLayoutFlags(middleText,
AbsoluteLayoutFlags.None);
AbsoluteLayout.SetLayoutBounds(middleText,
new Rectangle(100f, 200f, 200f, 50f));
simpleLayout.Children.Add(topLeftText);
simpleLayout.Children.Add(middleText);
}
適用於 Microsoft.Maui.Controls 的 XAML 支援類別的下列附加屬性 AbsoluteLayout :
附加屬性 | 值 |
---|---|
AbsoluteLayout.LayoutBounds | 以逗號分隔的清單,可能是具有空格的四個值,可指定周框的位置和維度。 清單中的前兩個值必須代表數位。 後面兩個值可以是數位,或字串 「AutoSize」。 |
AbsoluteLayout.LayoutFlags | AbsoluteLayoutFlags列舉值名稱: |
應用程式開發人員可以使用 XAML 搭配 類別來配置元素 AbsoluteLayout 。 下列範例會在 內AbsoluteLayout放置藍色BoxView:
<AbsoluteLayout VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand">
<BoxView AbsoluteLayout.LayoutBounds="0.25, 0.25, 0.5, 0.5"
Color="Blue"
AbsoluteLayout.LayoutFlags="All" />
</AbsoluteLayout>
類別 AbsoluteLayout 可以依比例單位、裝置單位或兩者的組合來配置其子元素。 指定將定義子元素設定界限的結構時 Rectangle ,應用程式開發人員應該記住下列幾點:
- 對於高度和寬度符合螢幕的專案,範圍 [0,1] 中的比例位置維度代表完全在螢幕上的項目,不論高度、寬度或兩者都是以裝置或比例單位指定。
- 上述點表示,若要在螢幕右下角指定元素,且寬度為一半且一半為螢幕,值為 AbsoluteLayoutFlags
All
,應用程式開發人員會指定 “1.0, 1.0, 0.5, 0.5”。 - 應用程式開發人員可能會不小心造成子元素,其中一個或兩個大小維度都依比例指定,以部分顯示在螢幕外,或完全隱藏,方法是指定沒有足夠空間供子系計算大小的裝置單位位置。
- 周框 Rectangle 結構的每個部分都會根據 AbsoluteLayoutFlags 控制它的值來解譯。 例如,指定的矩形可能會有 X 座標,以裝置單位為單位、以比例為單位的 Y 座標、以比例為單位的高度,以及裝置單位的寬度,或任何其他裝置和比例單位組合。
- 使用子系上目前的 AbsoluteLayoutFlags 集合來解譯的矩形,代表部分或完全關閉螢幕的周框方塊,例如,具有大於螢幕寬度的寬度,可能會產生非預期的結果。
建構函式
AbsoluteLayout() |
將子項目放在絕對位置。 |
欄位
_layoutManager |
將子項目放在絕對位置。 (繼承來源 Layout) |
AutoSize |
指出子系的寬度或高度大小應該調整為子系原生大小的值。 |
LayoutBoundsProperty |
附加屬性 的可系結屬性 |
LayoutFlagsProperty |
附加屬性 的可系結屬性 |
propertyMapper |
表示檢視的內部 PropertyMapper。 (繼承來源 View) |
屬性
AnchorX |
取得或設定相對於專案界限的任何轉換作業中心點的 X 元件。 這是可繫結屬性。 (繼承來源 VisualElement) |
AnchorY |
取得或設定相對於專案界限的任何轉換作業中心點的 Y 元件。 這是可繫結屬性。 (繼承來源 VisualElement) |
AutomationId |
取得或設定值,允許自動化架構尋找此項目並與之互動。 (繼承來源 Element) |
Background |
取得或設定 Brush 將用來填滿專案背景的 。 這是可繫結屬性。 (繼承來源 VisualElement) |
BackgroundColor |
取得或設定將 Color 填滿專案背景的 。 這是可繫結屬性。 (繼承來源 VisualElement) |
Batched |
取得值,這個值表示這個專案有批次變更。 (繼承來源 VisualElement) |
Behaviors |
取得與這個專案相關聯的物件清單 Behavior 。 這是唯讀的可繫結屬性。 (繼承來源 VisualElement) |
BindingContext |
取得或設定 對象,這個物件包含系結屬性所屬之系結屬性的目標屬性 BindableObject。 這是可繫結屬性。 (繼承來源 BindableObject) |
Bounds |
取得裝置獨立單位中元素的界限。 (繼承來源 VisualElement) |
CascadeInputTransparent |
將子項目放在絕對位置。 (繼承來源 Layout) |
Children |
供 Microsoft.Maui.Controls 平台內部使用。 (繼承來源 Layout) |
class |
將子項目放在絕對位置。 (繼承來源 NavigableElement) |
ClassId |
取得或設定值,用來識別語意類似項目的集合。 (繼承來源 Element) |
Clip |
指定專案的裁剪區域。 這是可繫結屬性。 (繼承來源 VisualElement) |
Count |
將子項目放在絕對位置。 (繼承來源 Layout) |
DesiredSize |
取得這個項目在版面配置處理序的測量傳遞期間所計算的大小。 (繼承來源 VisualElement) |
DisableLayout |
取得值,這個值表示已停用這個專案的配置。 (繼承來源 VisualElement) |
Dispatcher |
取得建立這個可系結物件時可用的發送器,否則會嘗試尋找最接近的可用發送器, (可能是視窗/應用程式的) 。 (繼承來源 BindableObject) |
EffectControlProvider |
供 .NET MAUI 內部使用。 (繼承來源 Element) |
Effects |
取得或設定將在運行時間套用至 元素的樣式和屬性。 (繼承來源 Element) |
FlowDirection |
取得或設定配置流程方向。 這是可繫結屬性。 (繼承來源 VisualElement) |
Frame |
取得或設定這個項目位於畫面上的框架。 (繼承來源 VisualElement) |
GestureController |
將子項目放在絕對位置。 (繼承來源 View) |
GestureRecognizers |
與此檢視建立關聯的筆勢辨識器集合。 (繼承來源 View) |
Handler |
取得或設定 IViewHandler 與這個項目相關聯的 。 (繼承來源 VisualElement) |
Height |
取得此項目的目前呈現高度。 這是唯讀的可繫結屬性。 (繼承來源 VisualElement) |
HeightRequest |
取得或設定此項目所需的高度覆寫項。 這是可繫結屬性。 (繼承來源 VisualElement) |
HorizontalOptions |
取得或設定 , LayoutOptions 定義元素在版面配置週期中的配置方式。 這是可繫結屬性。 (繼承來源 View) |
Id |
取得值,這個值可用來在應用程式執行期間唯一識別專案。 (繼承來源 Element) |
IgnoreSafeArea |
將子項目放在絕對位置。 (繼承來源 Layout) |
InputTransparent |
取得或設定值,指出這個專案是否會在用戶互動期間響應點擊測試。 這是可繫結屬性。 (繼承來源 VisualElement) |
IsClippedToBounds |
取得或設定值,這個值決定 Layout 是否應該將其子系裁剪到其界限。 (繼承來源 Layout) |
IsEnabled |
取得或設定值,這個值指出使用者介面中是否已啟用此項目。 這是可繫結屬性。 (繼承來源 VisualElement) |
IsEnabledCore |
這個值代表累計 IsEnabled 值。 如果值將會變更,則覆寫這個屬性的所有類型也需要叫用 RefreshIsEnabledProperty () 方法。 (繼承來源 VisualElement) |
IsFocused |
取得值,這個值指出此項目目前是否為焦點。 這是可繫結屬性。 (繼承來源 VisualElement) |
IsInPlatformLayout |
取得或設定值,這個值表示這個專案目前正在執行平臺配置週期。 (繼承來源 VisualElement) |
IsLoaded |
指出專案是否連接到主物件樹狀結構。 (繼承來源 VisualElement) |
IsPlatformEnabled |
取得或設定值,這個值表示是否啟用這個項目的平臺對等專案。 (繼承來源 VisualElement) |
IsPlatformStateConsistent |
取得或設定值,這個值表示這個專案目前與平臺對等項目狀態一致。 (繼承來源 VisualElement) |
IsReadOnly |
將子項目放在絕對位置。 (繼承來源 Layout) |
IsVisible |
取得或設定值,這個值會決定此元素是否會在畫面上顯示,並佔用版面配置的空間。 這是可繫結屬性。 (繼承來源 VisualElement) |
Item[Int32] |
將子項目放在絕對位置。 (繼承來源 Layout) |
LogicalChildren |
已淘汰.
供 Microsoft.Maui.Controls 平台內部使用。 (繼承來源 Element) |
Margin |
取得或設定檢視的邊界。 (繼承來源 View) |
MaximumHeightRequest |
取得或設定專案在版面配置期間要求的最大高度。 這是可繫結屬性。 (繼承來源 VisualElement) |
MaximumWidthRequest |
取得或設定專案在版面配置期間要求的最大寬度。 這是可繫結屬性。 (繼承來源 VisualElement) |
MinimumHeightRequest |
取得或設定元素在版面配置期間要求的最低高度。 這是可繫結屬性。 (繼承來源 VisualElement) |
MinimumWidthRequest |
取得或設定元素在版面配置期間要求的最低寬度。 這是可繫結屬性。 (繼承來源 VisualElement) |
Navigation |
將子項目放在絕對位置。 (繼承來源 NavigableElement) |
NavigationProxy |
將子項目放在絕對位置。 (繼承來源 NavigableElement) |
Opacity |
取得或設定套用至項目 (呈現時) 的不透明度值。 這個值的範圍是 0 到 1;超出此範圍的值將會設定為最接近的有效值。 這是可繫結屬性。 (繼承來源 VisualElement) |
Padding |
取得或設定 Layout 的內部填補。 (繼承來源 Layout) |
Parent |
取得或設定這個專案的父代 Element 。 (繼承來源 Element) |
RealParent |
供 .NET MAUI 內部使用。 (繼承來源 Element) |
Resources |
取得或設定本機資源字典。 (繼承來源 VisualElement) |
Rotation |
取得或設定呈現元素時繞著 Z 軸 (仿射旋轉) 的旋轉 (度)。 這是可繫結屬性。 (繼承來源 VisualElement) |
RotationX |
取得或設定呈現元素時繞著 X 軸 (透視旋轉) 的旋轉 (度)。 這是可繫結屬性。 (繼承來源 VisualElement) |
RotationY |
取得或設定呈現元素時繞著 Y 軸 (透視旋轉) 的旋轉 (度)。 這是可繫結屬性。 (繼承來源 VisualElement) |
Scale |
取得或設定套用至項目的縮放比例。 這是可繫結屬性。 (繼承來源 VisualElement) |
ScaleX |
取得或設定要套用至 X 方向的小數位數值。 這是可繫結屬性。 (繼承來源 VisualElement) |
ScaleY |
取得或設定要套用至 Y 方向的小數位數值。 這是可繫結屬性。 (繼承來源 VisualElement) |
Shadow |
取得或設定 專案所轉換的陰影效果。 這是可繫結屬性。 (繼承來源 VisualElement) |
Style |
將子項目放在絕對位置。 (繼承來源 NavigableElement) |
StyleClass |
將子項目放在絕對位置。 (繼承來源 NavigableElement) |
StyleId |
取得或設定使用者定義值來唯一識別項目。 (繼承來源 Element) |
TranslationX |
取得或設定項目的 X 轉譯差異。 這是可繫結屬性。 (繼承來源 VisualElement) |
TranslationY |
取得或設定項目的 Y 轉譯差異。 這是可繫結屬性。 (繼承來源 VisualElement) |
Triggers |
取得與這個專案相關聯的物件清單 TriggerBase 。 這是唯讀的可繫結屬性。 (繼承來源 VisualElement) |
VerticalOptions |
取得或設定 , LayoutOptions 定義元素在版面配置週期中的配置方式。 這是可繫結屬性。 (繼承來源 View) |
Visual |
取得或設定實 IVisual 作,這個實作會覆寫專案的視覺外觀。 這是可繫結屬性。 (繼承來源 VisualElement) |
Width |
取得這個專案目前的寬度。 這是唯讀的可繫結屬性。 (繼承來源 VisualElement) |
WidthRequest |
取得或設定此項目所需的寬度覆寫項。 這是可繫結屬性。 (繼承來源 VisualElement) |
Window |
Window取得與項目相關聯的 。 這是唯讀的可繫結屬性。 (繼承來源 VisualElement) |
X |
取得此項目的目前 X 位置。 這是唯讀的可繫結屬性。 (繼承來源 VisualElement) |
Y |
取得此項目的目前 Y 位置。 這是唯讀的可繫結屬性。 (繼承來源 VisualElement) |
ZIndex |
取得或設定版面配置中專案的前至后 z 索引。 這是可繫結屬性。 (繼承來源 VisualElement) |
方法
事件
明確介面實作
擴充方法
適用於
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應