Search code examples
androidimagedefaultprofilealphabetical

How to add Alphabetical profile pictures in android studio?


I want to add a default profile picture for my logged in user in my Android application. The way android marshmallow and above android version provides default alphabetical contact picture in contacts. There is a similar application "Micopi Pico". I want to use such functionality in my Android application to display the alphabetical profile picture as user's default profile picture. Is there any library or API or any method to do so? please help me.


Solution

  • There are many libraries to do that, here is an example, a library called Text Drawable (Click here to know more)

    Import with Gradle:

    repositories{
        maven {
            url 'http://dl.bintray.com/amulyakhare/maven'
        }
    }
    
    dependencies {
        compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
    }
    

    Usage :

    TextDrawable drawable = TextDrawable.builder()
                .buildRect("A", Color.RED);
    
    ImageView image = (ImageView) findViewById(R.id.image_view);
    image.setImageDrawable(drawable);
    

    You can go through the documentation to know more about the usage.

    You should always try searching for a solution to your problem before asking a question in stack overflow.