Margins in Android
I want to display dotted margin in table layout in my application. Is it possible or not ? If开发者_运维问答 yes then how..
Then try this
<TableRow android:layout_height="wrap_content" android:id="@+id/tableRow1" android:background="@drawable/dot"
android:layout_width="fill_parent">
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="Your text"></TextView>
</TableRow>
I have set the background dotted image in the table row
Suppose you need to give margin of 10 dip in your tablelayout. So instead of giving margin of 10 dip, you can use an image having dots of your choice with the calculated size using the below formula:
pixels = dps * (density / 160)
Here is the code
<?xml version="1.0" encoding="utf-8"?>
<TableLayout android:layout_height="wrap_content" android:stretchColumns="1"
android:id="@+id/tableLayout1" android:layout_width="wrap_content">
<TableRow android:layout_height="wrap_content" android:id="@+id/tableRow1"
android:layout_width="fill_parent">
<ImageView android:layout_width="wrap_content" android:src="@drawable/dot"
android:layout_height="fill_parent"></ImageView>
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content" android:text="Your text"></TextView>
<ImageView android:layout_width="wrap_content" android:src="@drawable/dot"
android:layout_height="fill_parent"></ImageView>
</TableRow>
</TableLayout>
精彩评论