{"id":297,"date":"2017-01-11T12:46:38","date_gmt":"2017-01-11T12:46:38","guid":{"rendered":"http:\/\/www.josejavierfm.es\/blog\/?p=297"},"modified":"2017-01-11T13:05:37","modified_gmt":"2017-01-11T13:05:37","slug":"modificaciones-sobre-boton-flotante","status":"publish","type":"post","link":"https:\/\/www.josejavierfm.es\/blog\/2017\/01\/11\/modificaciones-sobre-boton-flotante\/","title":{"rendered":"Modificaciones sobre boton flotante"},"content":{"rendered":"<p>Partiendo del componente <a href=\"http:\/\/joaquimley.com\/FabOptions\/\" target=\"_blank\">FabOptions<\/a><\/p>\n<p><a href=\"http:\/\/www.josejavierfm.es\/blog\/wp-content\/uploads\/2017\/01\/2017-01-11-13_45_41-FabOptions-open-source-library-\u00b7-Joaquim-Ley.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-299\" src=\"http:\/\/www.josejavierfm.es\/blog\/wp-content\/uploads\/2017\/01\/2017-01-11-13_45_41-FabOptions-open-source-library-\u00b7-Joaquim-Ley-300x84.png\" alt=\"\" width=\"300\" height=\"84\" srcset=\"https:\/\/www.josejavierfm.es\/blog\/wp-content\/uploads\/2017\/01\/2017-01-11-13_45_41-FabOptions-open-source-library-\u00b7-Joaquim-Ley-300x84.png 300w, https:\/\/www.josejavierfm.es\/blog\/wp-content\/uploads\/2017\/01\/2017-01-11-13_45_41-FabOptions-open-source-library-\u00b7-Joaquim-Ley.png 484w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>A\u00f1adiendo en la clase FabOptions.java el\u00a0m\u00e9todo:<br \/>\n<code><br \/>\npublic void changeColorbackground(int color){<br \/>\nDrawable d = mBackground.getBackground();<br \/>\nd = DrawableCompat.wrap(d);<br \/>\nDrawableCompat.setTint(d.mutate(), color);<\/code><\/p>\n<p>}<br \/>\npublic void changeColor(int color){<br \/>\nmFab.setBackgroundTintList(new ColorStateList(new int[][]{new int[]{0}}, new int[]{color}));<\/p>\n<p>}<\/p>\n<p>y llamandolo pasandole el color:<br \/>\n<code><br \/>\nfabOptions.changeColorBackground((getResources().getColor(R.color.verde));<br \/>\n<\/code><br \/>\nPodemos obtener resultados como:<br \/>\n<a href=\"http:\/\/www.josejavierfm.es\/blog\/wp-content\/uploads\/2017\/01\/Shutter_20170111_001.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-298\" src=\"http:\/\/www.josejavierfm.es\/blog\/wp-content\/uploads\/2017\/01\/Shutter_20170111_001-300x95.png\" alt=\"\" width=\"300\" height=\"95\" srcset=\"https:\/\/www.josejavierfm.es\/blog\/wp-content\/uploads\/2017\/01\/Shutter_20170111_001-300x95.png 300w, https:\/\/www.josejavierfm.es\/blog\/wp-content\/uploads\/2017\/01\/Shutter_20170111_001.png 510w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Y para cambiar el color del boton principal:<br \/>\n<code><br \/>\nfabOptions.changeColor((getResources().getColor(R.color.verde2));<br \/>\n<\/code><\/p>\n<p><a href=\"http:\/\/www.josejavierfm.es\/blog\/wp-content\/uploads\/2017\/01\/Shutter_20170111_002.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-302\" src=\"http:\/\/www.josejavierfm.es\/blog\/wp-content\/uploads\/2017\/01\/Shutter_20170111_002-300x95.png\" alt=\"\" width=\"300\" height=\"95\" srcset=\"https:\/\/www.josejavierfm.es\/blog\/wp-content\/uploads\/2017\/01\/Shutter_20170111_002-300x95.png 300w, https:\/\/www.josejavierfm.es\/blog\/wp-content\/uploads\/2017\/01\/Shutter_20170111_002.png 476w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n\n<div class=\"twitter-share\"><a href=\"https:\/\/twitter.com\/intent\/tweet?via=josejavierfm\" class=\"twitter-share-button\">Twittear<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Partiendo del componente FabOptions A\u00f1adiendo en la clase FabOptions.java el\u00a0m\u00e9todo: public void changeColorbackground(int color){ Drawable d = mBackground.getBackground(); d = DrawableCompat.wrap(d); DrawableCompat.setTint(d.mutate(), color); } public void changeColor(int color){ mFab.setBackgroundTintList(new ColorStateList(new int[][]{new int[]{0}}, new int[]{color})); } y llamandolo pasandole el color: fabOptions.changeColorBackground((getResources().getColor(R.color.verde)); Podemos obtener resultados como: Y para cambiar el color del boton principal: fabOptions.changeColor((getResources().getColor(R.color.verde2));<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/www.josejavierfm.es\/blog\/wp-json\/wp\/v2\/posts\/297"}],"collection":[{"href":"https:\/\/www.josejavierfm.es\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.josejavierfm.es\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.josejavierfm.es\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.josejavierfm.es\/blog\/wp-json\/wp\/v2\/comments?post=297"}],"version-history":[{"count":3,"href":"https:\/\/www.josejavierfm.es\/blog\/wp-json\/wp\/v2\/posts\/297\/revisions"}],"predecessor-version":[{"id":303,"href":"https:\/\/www.josejavierfm.es\/blog\/wp-json\/wp\/v2\/posts\/297\/revisions\/303"}],"wp:attachment":[{"href":"https:\/\/www.josejavierfm.es\/blog\/wp-json\/wp\/v2\/media?parent=297"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.josejavierfm.es\/blog\/wp-json\/wp\/v2\/categories?post=297"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.josejavierfm.es\/blog\/wp-json\/wp\/v2\/tags?post=297"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}