summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android/Renderers/PageContainer.cs
blob: 435ee7cfb24f3490b8d00edea5f18505eb20e5ab (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
31
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.View);
			Child = child;
			IsInFragment = inFragment;
			Id = Platform.GenerateViewId();
		}

		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.View.Measure(widthMeasureSpec, heightMeasureSpec);
			SetMeasuredDimension(Child.View.MeasuredWidth, Child.View.MeasuredHeight);
		}
	}
}