Cheok Yan Cheng
Cheok Yan Cheng

Reputation: 42690

Having divider in LinerLayout by using android:divider and android:showDividers

I try to have 2 dividers in between 3 text views. I use android:divider and android:showDividers. However, no vertical divider being shown. I was wondering, is there anything I had missed out?

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="48dp"
    android:orientation="horizontal"
    android:divider="?android:attr/dividerVertical"
    android:dividerPadding="12dip"
    android:showDividers="middle" >

    <TextView
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:gravity="center_vertical|center_horizontal"
        android:text="ABC" />

    <TextView
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:gravity="center_vertical|center_horizontal"
        android:text="EFG" />

    <TextView
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:gravity="center_vertical|center_horizontal"
        android:text="HIJ" />

</LinearLayout>

Upvotes: 6

Views: 3670

Answers (1)

Ahmad
Ahmad

Reputation: 72553

Dividers in LinearLayouts are only available from API 11. I assume you are testing on a lower API. See the Docs for more information. However you can use IcsLinearlayout from the ABS package for backwards compatibility.

Upvotes: 7

Related Questions