Reputation: 97
I want to create a Xamarin Forms Editor Control that changes its height when it gets filled(Adds a new line when space in previous line finished). I'm only interested in WinPhone and Android Platfroms.
The Editor itself doesn't support such property.
I know that the Android native control (EditText) supports it (Not sure about the WinPhone variant, TextBox). But I'm not sure how to implement it.
It will be very helpful if someone can explain me how to create the renderers for these platforms.
I found this partial solution, it kind of works fine but it is not so natural(as for example EditText in Android).
class RoundedEditor : Editor
{
public RoundedEditor()
{
this.TextChanged += (sender, e) => { this.InvalidateMeasure(); };
}
}
I'll be glad if someone will provide a better solution.
Here are the results of how it works now:
UWP
Writing first line:
pressing enter:
The previous line is not showed completely as I would like.
Android
In android it actually works great:
Upvotes: 0
Views: 755
Reputation: 31
You will have to implement a custom Android EditText, and then use it for your XamarinForms control (by implementing a custom renderer for it)
Take a look at this implementation of resizable EditText: https://github.com/ViksaaSkool/AutoFitEditText
You'd have to translate it to C# obviously, but its a great start point.
Upvotes: 0