Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

android

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>
like image 741
Cheok Yan Cheng Avatar asked Mar 01 '13 20:03

Cheok Yan Cheng


People also ask

What is android divider?

The divider will display the correct default Material colors without the use of a style flag in a layout file. Make sure to set android:layout_height="wrap_content" to ensure that the correct thickness is set for the divider.

What is LinearLayout in android with example?

LinearLayout is a view group that aligns all children in a single direction, vertically or horizontally. You can specify the layout direction with the android:orientation attribute. Note: For better performance and tooling support, you should instead build your layout with ConstraintLayout.

How do you put line through text on android?

If you want to show a strike-through text you can do it programming using PaintFlags. You can set paint flags Paint. STRIKE_THRU_TEXT_FLAG to a TextView and it will add a strike-through to the text. TextView textView = (TextView) findViewById(R.


1 Answers

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.

like image 69
Ahmad Avatar answered Sep 30 '22 20:09

Ahmad