Heart shaped button in android

后端 未结 2 905

I have this application that I am working on and the user can mark some items as a favorite. I want to use a heart shaped button for this functionality instead of the casual one

2条回答
  •  忘掉有多难
    2021-02-10 09:39

    You can use VectorAssets as below in XML.

    
        
    
    

    You can create VectorAssets doing: new Vector Asset > Change Icon -- Here you can choose love vector asset. These VectorAssets, you can store in the drawable folder. Then you can import than in your XML layout file as

    @drawable/
    

    For the demo, please see below picture. The VectorAsset XML file is ic_favorite_black_24dp

    You can change the color of the VectorAsset also. On click, you can replace VectorAsset with another Red colored VectorAsset to represent it favorite and so on.

提交回复
热议问题