Change image Floating Action Button Android

前端 未结 9 479
旧时难觅i
旧时难觅i 2020-12-16 09:19

I used this library https://github.com/futuresimple/android-floating-action-button. How can I change the image of the main button? I want to change the button image right af

9条回答
  •  情歌与酒
    2020-12-16 09:53

    What I am using as follows,

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab_btn);
    
    // State 1 -on
    
    fab.setImageDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.fab_on));
    
    // State  2 - off
    
    fab.setImageDrawable(ContextCompat.getDrawable(getActivity(), R.drawable.fab_off));
    

    Hope this will help you

提交回复
热议问题