xamarin.android - Adding Labels and images dynamically to a custom view in Android -


I have custom view that I get to the user's signature on Android Created for . Views is working fine and I'm getting the result that I need. Now I need to add watermarks (small texts on the four corners of the background of the signature box). I am doing this on Android and iOS, so what I did in iOS was to create the label s, and using some configurations, I used the frame (x, y, Width, heigh) at runtime and add them to custom view. It works very well on iOS (mono touch). Now I need to do the same thing on monophor android

I've got this so far:

 // My customview is public Hstakshrdrishy: See, Aisnecr V {// Some Irrlvennt code here // Then Ondra (where I draw the signature line) protected override void OnDraw (canvas) {DrawWaterMarks (); } Private Zero DrawWaterMarks () {// First of all, I am creating a relative layout and add labels _relativeLayout = new relative layout (this.Context) in my customview; Var LayoutParam = New Relative Layout LayoutParms (this.Maharavarth, this.Maybe heights); _relativeLayout.LayoutParameters = LayoutParam; Var viewGroup = (ViewGroup) this.RootView; ViewGroup.AddView (_relativeLayout); // I then make labels Ilabel label = new Label (context); the label. Layout (watermark .x, watermark .0, 0,0); EnsureAddingWatermarkControl (label); } Private Zero EnsureAddingWatermarkControl (see view) {if (_relativeLayout! = See & tap! = Tap) {_relativeLayout.RemoveView (see); _relativeLayout.AddView (see, see Sensitivity width, see Sensitive); This.Invalidate (); }}} 

Now the code above all functions is fine and there is no exception or error, but I can not see any of my labels

I am assuming that this There is a relative layout and dimension settings and the way I am doing it, but the problem is not where the problem is.

Any help would be greatly appreciated

There may be a problem here, This is already onDraw .

After this comment or

 , be sure to add your relative layout  in the rootview to .  

// First of all, I am creating a relative layout and add it to my customview to capture the label

First, add your label to your relative layout, and then you can assign your relative layout to your customView (as mentioned in the code snippet you provided )

should be like code

  Private Zero DrawWater Marks () {ILabel label = new label (reference) ; the label. Layout (watermark .x, watermark .0, 0,0); EnsureAddingWatermarkControl (label); } Private Zero EnsureAddingWatermarkControl {see (see! = Tap) {_relativeLayout = New Relative Layout (this.Context); Var LayoutParam = New Relative Layout LayoutParms (this.Maharavarth, this.Maybe heights); _relativeLayout.LayoutParameters = LayoutParam; _relativeLayout.AddView (see, see Sensitivity width, see Sensitive); Var viewGroup = (ViewGroup) this.RootView; ViewGroup.AddView (_relativeLayout); This.Invalidate (); }}  

Comments