Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Divider for vertical LinearLayout?

So I'm trying to put a divider between views in a LinearLayout using the XML android:divider attribute. When I use a vertical LinearLayout, no divider shows up. When I use a horizontal LinearLayout, the divider shows up and works fine. Here is the drawable I'm using for the divider (drawable/one.xml):

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <size android:width="1dip" />
    <solid android:color="#FFFFFF" />
</shape>

And here is my LinearLayout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:divider="@drawable/one"
              android:dividerPadding="10dp"
              android:showDividers="middle">
<TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="test1"
            />

<TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="test2"
            />

</LinearLayout>

Is it not possible to use the divider attribute with a vertical linear layout or am I missing something?

like image 685
Polaris878 Avatar asked Oct 22 '13 01:10

Polaris878


1 Answers

For the vertical layout, in the drawable, I think you need to replace

  <size android:width="1dip" />

with

  <size android:height="1dip" />
like image 63
scrayne Avatar answered Sep 30 '22 14:09

scrayne