How to change android design support library FAB Button border color?

后端 未结 4 1348
梦毁少年i
梦毁少年i 2020-12-03 01:42

I want to change fab button border color. border color is white, inside color is black or transparent

I\'d like my button to look like this:

4条回答
  •  盖世英雄少女心
    2020-12-03 02:02

    First create a .xml shape resource let's call it ring.xml and put the following in it:

    
    
        
            
    
                
                
            
        
        
            
        
    
    
    

    You will have to play with the thickness and innerRadius attributes to get it right, but that should do it! Also the bitmap source is just a filler, you want to put your F image there.

    Then where you declare your fab, reference your ring like such:

    android:background="@drawable/ring"
    

    OR

    In your java code, do the following:

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setBackgroundResource(R.drawable.ring);
    

    Hope this helps!

提交回复
热议问题