java - Palette (Android Support v22) doesn't generate Swatches -
first of all, never used palette, when wanted start it, see tutorials , blogs talk v21 , not v22.
my problem have swatch (in position 0 of swatch's array [palette.getswatches().get(0)]) returns black (title , body), here example i'm using this, maybe it's wrong i'm copying https://developer.android.com/reference/android/support/v7/graphics/palette.html
palette.from(bitmapfactory.decoderesource(getresources(),r.drawable.prueba2)).generate(new palette.paletteasynclistener() { @override public void ongenerated(palette palette) { text.settextcolor(palette.getvibrantswatch().getbodytextcolor()); text.setbackgroundcolor(palette.getvibrantswatch().gettitletextcolor()); } });
when start app (i have activity textview , imageview) closes saying this
caused by: java.lang.nullpointerexception: attempt invoke virtual method 'int android.support.v7.graphics.palette$swatch.getbodytextcolor()' on null object reference @ com.alfondo.projectpalette.mainactivity.oncreate(mainactivity.java:33)"
edit: drawable. (i cant't post imgs) http://imgur.com/ygv9xvs
first create bitmap of image using picasso palette color of image , set color collapsible toolbar
// bitmap of image , generate toolbar color passing bitmap palette bitmap bitmap = bitmapfactory.decoderesource(getresources(), r.drawable.nature); palette.from(bitmap).generate(new palette.paletteasynclistener() { // muted color bitmap using palette , set collapsible toolbar @override public void ongenerated(palette palette) { collapsingtoolbarlayout.setcontentscrimcolor(palette.getmutedcolor(getresources().getcolor(r.color.colorprimary))); collapsingtoolbarlayout.setstatusbarscrimcolor(palette.getmutedcolor(getresources().getcolor(r.color.colorprimarydark))); } });
Comments
Post a Comment