Reputation: 3053
I have a requirement where a field in a Xamarin Forms app is allowed to have only numbers, spaces and dashes. Numeric keyboard layout appears to be perfect for this purpose - the only trouble - the space and dash buttons do not appear to work? Is there any way to enable these, specifically on Android - as that is the primary target platform.
Buttons in question are highlighted.
<Entry
x:Name="BarcodeEntry"
Margin="12,0"
HeightRequest="40"
Placeholder="Barcode"
Style="{StaticResource BorderlessEntryStyle}"
Keyboard="Numeric"
Text="{Binding Barcode.Value, Mode=TwoWay}">
Control is bound to this property:
private string _barcode;
public string Barcode
{
get => _barcode;
set { SetProperty(ref _barcode, value); }
Upvotes: 3
Views: 1984
Reputation: 10968
For the numberic keyboard, we only have four related InputTypes.
For more details about the InputTypes, you could refer to the link below. https://developer.android.com/reference/android/widget/TextView#attr_android:inputType
If you want to use the space and dash buttons, you could use the Telephone keyboard. Or you could create your own custom keyboard.
Custom Keyboard: Numeric keyboard as default on Xamarin.Forms, but allow text (cross platform)
Upvotes: 4