blob: c79e6137bc9c2ee3f1c14a512e578799f25ac5c1 (
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
using Android.Content;
using Android.Views;
namespace Xamarin.Forms.Platform.Android
{
internal class ScrollViewContainer : ViewGroup
{
readonly ScrollView _parent;
View _childView;
public ScrollViewContainer(ScrollView parent, Context context) : base(context)
{
_parent = parent;
}
public View ChildView
{
get { return _childView; }
set
{
if (_childView == value)
return;
RemoveAllViews();
_childView = value;
if (_childView == null)
return;
IVisualElementRenderer renderer;
if ((renderer = Platform.GetRenderer(_childView)) == null)
Platform.SetRenderer(_childView, renderer = Platform.CreateRenderer(_childView));
if (renderer.ViewGroup.Parent != null)
renderer.ViewGroup.RemoveFromParent();
AddView(renderer.ViewGroup);
}
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
{
if (ChildCount > 0)
GetChildAt(0).Dispose();
RemoveAllViews();
_childView = null;
}
}
protected override void OnLayout(bool changed, int left, int top, int right, int bottom)
{
if (_childView == null)
return;
IVisualElementRenderer renderer = Platform.GetRenderer(_childView);
renderer.UpdateLayout();
}
protected override void OnMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
// we need to make sure we are big enough to be laid out at 0,0
if (_childView != null)
{
SetMeasuredDimension((int)Context.ToPixels(_childView.Bounds.Right + _parent.Padding.Right), (int)Context.ToPixels(_childView.Bounds.Bottom + _parent.Padding.Bottom));
}
else
SetMeasuredDimension((int)Context.ToPixels(_parent.Padding.Right), (int)Context.ToPixels(_parent.Padding.Bottom));
}
}
}
|