Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Posibility of mat-prefix and mat-suffix icons in textfield #32

Open
inONEL opened this issue Jul 16, 2019 · 2 comments
Labels
enhancement New feature or request

Comments

@inONEL
Copy link

inONEL commented Jul 16, 2019

It would be nice if we could add material icons to the textfield

@farfromrefug farfromrefug added the enhancement New feature or request label Sep 30, 2019
@kryoware
Copy link

kryoware commented Nov 9, 2020

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

Screenshot_20201109-114631

@farfromrefug
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants