Is there a simpler/better way to put a border/outline around my TextView?

So I wanted to have a TextView with a cool border around it. I couldn't find any standard way of doing it, so I came up with this:

@drawable/custom_bg_1: A blue rounded shape



    
    
    

@drawable/custom_bg_2: A white rounded shape



    
    
    

myactivity.xml: the xml for the activity




  

      

  

The outcome:

picture of blue border

What I am doing here is overlapping a white shape background inside a blue shape background to give the effect of a blue border. I can't imagine this is the best way to get this effect. I have seen other posts that attempt to solve this problem such as this and this, but I feel like they are just as much of a work around as my implementation.

Is there a better way or more standard way of simply putting a border around certain views such as a TextView or should I just stick with the way I am doing it?


EDIT

I changed custom_bg_2.xml to look like this:



    
    
    
    

And now I get this result:

blue and black border

It looks like I can achieve an outline by including in shape.

27
задан Community 23 May 2017 в 11:53
поделиться