View.HorizontalOptions 속성

정의

요소가 레이아웃 주기에 배치되는 방법을 정의하는 LayoutOptions를 가져오거나 설정합니다. 이는 바인딩 가능 속성입니다.

public Xamarin.Forms.LayoutOptions HorizontalOptions { get; set; }
member this.HorizontalOptions : Xamarin.Forms.LayoutOptions with get, set

속성 값

LayoutOptions 요소를 배치하는 방법을 정의하는 입니다. 달리 문서화되지 않는 한 기본값은 입니다 Fill .

설명

HorizontalOptions를 할당하면 부모 레이아웃에서 X축을 따라 사용할 수 있는 공간이 초과될 때 요소가 배치되는 방식이 수정됩니다. 또한 요소가 부모 레이아웃에서 X축의 남은 공간을 사용해야 하는지를 지정합니다. 레이아웃의 여러 자식이 확장되도록 설정된 경우 추가 공간이 비례적으로 분산됩니다.

이 예제에서는 4개의 뷰를 만들고 스택에 추가합니다. 각 보기는 서로 다른 방식으로 배치됩니다.

private View CreateButtons ()
{
  var button1 = new Button {Text = "LeftAligned", HorizontalOptions=LayoutOptions.Start};
  var button2 = new Button {Text = "CenterAligned", HorizontalOptions=LayoutOptions.Center};
  var button3 = new Button {Text = "EndAligned", HorizontalOptions=LayoutOptions.End};
  var button4 = new Button {Text = "Fill", HorizontalOptions=LayoutOptions.Fill};

  StackLayout stack = new StackLayout {
    Children = {
      button1,
      button2,
      button3,
      button4
    }
  };

  return stack;
}

적용 대상