Is there a way to show an image beside the placeholder text of a Text Field as shown in the attached image?
You can use the LeftView property to put something to the left of the text. If you want it to disappear when editing or when there is content then you will have to handle a few events and change the value of the LeftView property accordingly.
Thanks @adamkemp for your response.
I tried doing like you said but it did not work. Here is the complete scenario:
1) I have a text field called txtTest and an image view called imgTest
2) I have set an image source for the image view
3) For the text field, I have set its placeholder text to be 'Username'
4) In ViewDidLoad of my ViewController.cs file I wrote this.txtTest.LeftView = this.imgTest;
this.txtTest.LeftView = this.imgTest;
I thought I may see the image on the left but I just see the placeholder text and no image.
PS: For some reason, the screenshot attached to my original question has been removed, so I am attaching it again for quick reference.
Be sure you give the image view a size. After setting its image call SizeToFit on it.
@adamkemp, thanks a lot for pointing me to the right direction. LeftView was the way to go but the following line actually made the image show:
this.txtTest.LeftViewMode = UITextFieldViewMode.Always;
Xamarin Inc., as a wholly-owned Microsoft subsidiary acting as a separate legal entity, adheres to the Microsoft Privacy Statement: Privacy & cookies