Making layout borders with title in the top border in Android

This is a example in android for making a border for a RelativeLayout, with a title text in the center on the top border line. Something like this:

Border Title

activity_border_title_demo.xml, this is the layout xml for an activity or fragment. It has two LinearLayout views inside a RelativeLayout. The first LinearLayout for the top border with title in the center, the second LinearLayout for the topless border. Note, the first LinearLayout is not the root tag which is also a LinearLayout.




    
        
            
            
            
        
        
            
            
        
    


topless_border.xml, this file should defined in the drawable folder. Set this to the background of a LinearLayout or RelativeLayout, you will get borders on the left, right, and bottom but no top.



    
        
            
            
            
        
    

Complete example in Github

Search within Codexpedia

Custom Search

Search the entire web

Custom Search