コメント
コメントの投稿
※名前とタイトルが入力されていないコメントでは他のコメントとの区別ができません。
入力されていないコメントには返信しませんのであらかじめご了承くださいませ。
<ScrollView x:Name="scrollLayout"
Orientation = "Vertical"
VerticalOptions="FillAndExpand">
<RelativeLayout x:Name="rtLayout"
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand">
<!--ここにコンテンツを配置します -->
<ContentView x:Name="ctLayer" />
</RelativeLayout>
</ScrollView>
private void Initialize()
{
//centerLayoutの表示位置をスクロールポジションに合わせて表示する
//横位置を計算します
var centerX = Constraint.RelativeToParent(parent => (parent.Width / 2) - (this.ctLayer.Width / 2));
//縦位置を計算します
var centerY = Constraint.RelativeToParent(parent => (this.Height / 2) + this.scrollLayout.ScrollY - (this.ctLayer.Height / 2));
//XAMLにて設定済みの場合は一度削除する
rtLayout.Children.Remove(this.ctLayer);
//再計算後の位置で描画する
rtLayout.Children.Add(this.ctLayer, centerX, centerY);
}
private void Initialize()
{
RelativeLayout.SetBoundsConstraint(this.ctLayer,
BoundsConstraint.FromExpression(
() => new Rectangle(
(this.rtLayout.Width / 2) - (this.ctLayer.Width / 2),
(this.Height / 2) + this.scrollLayout.ScrollY - (this.ctLayer.Height / 2),
this.ctLayer.Width,
this.ctLayer.Height),
null));
}
※名前とタイトルが入力されていないコメントでは他のコメントとの区別ができません。
入力されていないコメントには返信しませんのであらかじめご了承くださいませ。