I have pretty simple custom view:
public class TestControl : RelativeLayout
{
private readonly Context _context;
private TextView _textLabel;
public TestControl(Context context) : base(context)
{
_context = context;
LayoutParameters = new LayoutParams(300, 200);
SetBackgroundColor(Color.Green);
_textLabel = new TextView(_context);
_textLabel.SetText("Test test test test test test",
TextView.BufferType.Normal);
_textLabel.SetTextColor(Android.Graphics.Color.Black);
_textLabel.LayoutParameters = new ViewGroup.LayoutParams(200, 50);
_textLabel.SetBackgroundColor(Color.Red);
AddView(_textLabel);
}
protected override void OnLayout(bool changed, int l, int t, int r, int
b)
{
}
}
When I try to add it as a view into my main activity layout:
var myControl = new TestControl(this);
myMainLayout.AddView(myControl);
I see only green recangle(300 x 200) but no TextView.
What am I doing wrong? Any help on how to show at least TextView inside some
colored layout much appreciated, as I need actualy much more complicated
custom view.
Thanks in advance.
--
View this message in context:
http://mono-for-android.1047100.n5.nabble.com/MonoDroid-custom-View-doesn-t-show-child-tp5710744.html
Sent from the Mono for Android mailing list archive at Nabble.com.
_______________________________________________
Monodroid mailing list
[email protected]
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid