ui-material-components
ui-material-components copied to clipboard
[Feature Request] Posibility of mat-prefix and mat-suffix icons in textfield
trafficstars
It would be nice if we could add material icons to the textfield
Just in case someone still needs this. Not sure if this is the right way to do it tho. Tested on Android 9 - NS 6.x
Code
import { android as androidApp } from 'tns-core-modules/application'
...
// loaded event
textFieldLoaded({ object }) {
// Grab Native view
const inputLayout = object.android
// Grab icon from res (replace "com.example.app" with your package name. "ic_add" with your icon name)
const icon = com.example.app.R.drawable.ic_add
// Convert it into a drawable for android
const iconDrawable = androidApp.context.getResources().getDrawable(icon)
inputLayout.setPrefixText("+63 ")
inputLayout.setStartIconDrawable(iconDrawable)
}
Result

@kryoware I think it is the right way. Want to make a PR to add that both on iOS and Android ?