install android studio

Color Picker in Android Studio

Color Picker:

Color Picker is the menu popup of colors which is used to select colors for the tasks in Android App.

Implementation:

1. activity_main.xml:

com.android.ColorPickerView
        android:id="@+id/colorPickerView"
        android:layout_width="300dp"
        android:layout_height="300dp"
        app:palette="@drawable/palette"
        app:selector="@drawable/wheel" />

 

2.MainActivity.java:


 public class FontManager
{
static public HashMap< String, String > enumerateFonts()
{
    String[] fontdirs = { "/system/fonts", "/system/font", "/data/fonts" };
    HashMap< String, String > fonts = new HashMap< String, String >();
    TTFAnalyzer analyzer = new TTFAnalyzer();

    for ( String fontdir : fontdirs )
    {
        File dir = new File( fontdir );

        if ( !dir.exists() )
            continue;

        File[] files = dir.listFiles();

        if ( files == null )
            continue;

        for ( File file : files )
        {
            String fontname = analyzer.getTtfFontName( file.getAbsolutePath() );

            if ( fontname != null )
                fonts.put( file.getAbsolutePath(), fontname );
        }
    }

    return fonts.isEmpty() ? null : fonts;
}
}

 

 

About the author

Generic Bytes

Hi! we are from Generic Bytes an aspiring bloggers with an obsession of things tech.This blog is dedicated to people who want to learn the technology.

View all posts

Leave a Reply

Your email address will not be published. Required fields are marked *