Nativescript: Ability to style EditableTextBase's hint property

Created on 11 Sep 2015  路  14Comments  路  Source: NativeScript/NativeScript

Right now there's either no clear way to style the placeholder hint text for EditableTextBase or that you can't. Particularly changing the colour.

possible properties could be:

  • placeholder-color

Unsure if these inherit from the normal font properties, but:

  • placeholder-font
  • placeholder-font-size
  • placeholder-font-weight
  • placeholder-font-family
  • placeholder-text-align
feature

Most helpful comment

I've just added placeholder-color css property with #2644 which will work for TextField (Android and iOS) and TextView (Android). Unfortunately iOS also supports other style options like font, weight ..., but for Android we can change only color. Therefore we end up with a support for placeholder(hint) color only.

All 14 comments

The way I am currently doing it for iOS:

textField.ios.attributedPlaceholder = NSAttributedString.alloc().initWithStringAttributes("placeholder text", new NSDictionary([UIColor.whiteColor()], [NSForegroundColorAttributeName]));

and Android (with the hint property set on the textfield object):

textField.android.setHintTextColor(android.graphics.Color.parseColor("#FFFFFF"));

One thing I noticed is that the hints for secure text fields have more letter spacing and font size than a regular textfield in Android by default for some reason.

+1

+1

+1

+1

Something that might help others.
In the "app/App_Ressources/Android/values/styles.xml", with the following changes you can control the TextInput's hint color.

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
    <style name="AppThemeBase" parent="Theme.AppCompat.Light.NoActionBar">
           ....
            <item name="android:editTextStyle">@style/Application</item>
           ....
        </style>

    <style name="Application" parent="Widget.AppCompat.EditText">
             <item name="android:textColorHint">#777777</item>
        </style>
</resources> 

This will effectively change the text hint color for Android platform only

+1

+1

+1

+1

+1

I've just added placeholder-color css property with #2644 which will work for TextField (Android and iOS) and TextView (Android). Unfortunately iOS also supports other style options like font, weight ..., but for Android we can change only color. Therefore we end up with a support for placeholder(hint) color only.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tjvantoll picture tjvantoll  路  58Comments

mspusta78 picture mspusta78  路  59Comments

tjvantoll picture tjvantoll  路  46Comments

valentinstoychev picture valentinstoychev  路  79Comments

ikhsan017 picture ikhsan017  路  55Comments