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>
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With