How to add border around linear layout except at the bottom?

后端 未结 4 783
时光说笑
时光说笑 2020-11-29 20:47

How to add border around linear layout except at the bottom ? LinearLayout needs to have border at left, top and right side but not at the bottom.

4条回答
  •  有刺的猬
    2020-11-29 21:39

    Create an XML file named border.xml in the drawable folder and put the following code in it.

     
     
       
        
           
        
         
          
          
          
        
           
      
    

    Then add a background to your linear layout like this:

             android:background="@drawable/border"
    

    EDIT :

    This XML was tested with a galaxy s running GingerBread 2.3.3 and ran perfectly as shown in image below:

    enter image description here

    ALSO

    tested with galaxy s 3 running JellyBean 4.1.2 and ran perfectly as shown in image below :

    enter image description here

    Finally its works perfectly with all APIs

    EDIT 2 :

    It can also be done using a stroke to keep the background as transparent while still keeping a border except at the bottom with the following code.

    
     
        
        
         
        
         
      
    

    hope this help .

提交回复
热议问题