summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android/Renderers/PageContainer.cs
blob: 06e33e18674b1e6744521732e16f69e54f711b51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using Android.Content;
using Android.Views;

namespace Xamarin.Forms.Platform.Android
{
	internal class PageContainer : ViewGroup
	{
		public PageContainer(Context context, IVisualElementRenderer child, bool inFragment = false) : base(context)
		{
			AddView(child.ViewGroup);
			Child = child;
			IsInFragment = inFragment;
		}

		public IVisualElementRenderer Child { get; set; }

		public bool IsInFragment { get; set; }

		protected override void OnLayout(bool changed, int l, int t, int r, int b)
		{
			Child.UpdateLayout();
		}

		protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec)
		{
			Child.ViewGroup.Measure(widthMeasureSpec, heightMeasureSpec);
			SetMeasuredDimension(Child.ViewGroup.MeasuredWidth, Child.ViewGroup.MeasuredHeight);
		}
	}
}