6

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>
Cheok Yan Cheng
  • 49,649
  • 117
  • 410
  • 768
  • 1
    I usually use simple Views for that. check this: http://stackoverflow.com/questions/5049852/android-drawing-separator-divider-line-in-layout – abbath Mar 01 '13 at 20:47

1 Answers1

7

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.

PureSpider
  • 378
  • 3
  • 20
Ahmad
  • 58,947
  • 17
  • 107
  • 133
  • using the IcsLinearLayout causes a weird error in the graphical designer for the previews , which shows "android.graphics.bitmap_delegate.nativeRecycle(I)Z" . is it possible to avoid it and fix it? – android developer Jun 13 '13 at 08:29
  • @androiddeveloper hmm not sure about that. The UI editor tends to have rendering issues a lot, so probably not, sorry. – Ahmad Jun 13 '13 at 11:31
  • but it worked fine before. it happens only when using API17 for the preview. – android developer Jun 13 '13 at 12:16