Same style for every row in Android's TableLayout

Is there any way in Android XML to set the same style (or style paramerers, like padding) for all rows in a TableLayout at once?

What I would like to avoid doing is:

<TableLayout> <TableRow style="@style/MyStyle">...</TableRow> <TableRow style="@style/MyStyle">...</TableRow> <TableRow style="@style/MyStyle">...</TableRow> <TableRow style="@style/MyStyle">...</TableRow> ... </TableLayout>

-------------Problems Reply------------

You can define your own styles by creating XML files on the res/values directory. So, let's suppose you want to have red and bold text, then you create a file with this content:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyRedTheme" parent="android:Theme.Light">
<item name="android:textAppearance">@style/MyRedTextAppearance</item>
</style>
<style name="MyRedTextAppearance" parent="@android:style/TextAppearance">
<item name="android:textColor">#F00</item>
<item name="android:textStyle">bold</item>
</style>
</resources>

You can name it like you want, for instance res/values/red.xml. Then, the only thing you have to do is using that view in the widgets that you want, for instance:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
style="@style/MyRedTheme"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is red, isn't it?"
/>
</LinearLayout>

For more referense click here

Category:android Views:1 Time:2018-10-03

Related post

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.167 (s). 11 q(s)