Android中的彩色选择器



如何在Android中使用彩色拾取器?我尝试了以下代码:

public class FontManager
{
// This function enumerates all fonts on Android system and returns the HashMap with the font
// absolute file name as key, and the font literal name (embedded into the font) as value.
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;
}
}

此代码会出现运行时间错误。提供一些样本。

我在代码中没有看到有关颜色挑选的任何内容吗?但是也许您可以只使用库来挑选颜色:Android-Color-picker

我想这么说。我已经使用Java为Android应用程序创建了自己的颜色选择器。添加您的项目非常简单。

请浏览一下:https://github.com/akashfulari/afscolorchooser

预览:结帐此预览

最新更新