How to add (vertical) divider to a horizontal LinearLayout?

后端 未结 11 698
有刺的猬
有刺的猬 2020-11-27 11:36

I\'m trying to add a divider to a horizontal linear layout but am getting nowhere. The divider just doesn\'t show. I am a total newbie with Android.

This is my layou

11条回答
  •  甜味超标
    2020-11-27 12:01

    If the answer of Kapil Vats is not working try something like this:

    drawable/divider_horizontal_green_22.xml

    
    
    
        
        
    
    
    

    layout/your_layout.xml

    LinearLayout 
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:id="@+id/llTopBar"
                android:orientation="horizontal"
                android:divider="@drawable/divider_horizontal_green_22"
                android:showDividers="middle"
               >
    

    I encountered an issue where the padding attribute wasn't working, thus I had to set the height of the divider directly in the divider.

    Note:

    If you want to use it in vertical LinearLayout, make a new one, like this: drawable/divider_vertical_green_22.xml

    
    
    
        
        
    
    
    

提交回复
热议问题