Android how to create triangle and rectangle shape programmatically?

前端 未结 7 1063
一整个雨季
一整个雨季 2020-11-29 01:15

How can we create ballon drawable shape as below. where we can change the color of it dynamically. \"enter

7条回答
  •  臣服心动
    2020-11-29 02:09

    First you can create one xml inside drawable folder

    That xml will be responsible for the border color of rectangle shape

    You can create such border shape with below code

    
     
       
        
           
        
         
          
          
          
        
           
      
    

    well this will create a required border to rectangle shape, you need to assign background of that rectangle shape with this drawable like this

    android:background="@drawable/bg"
    

    where bg is xml file name which has been saved on drawable folder

    After that you need to put that triangle exactly below to rectangle object.

    I hope you understood my logic

提交回复
热议问题