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"?>
<style name="MyRedTheme" parent="android:Theme.Light">
<item name="android:textAppearance">@style/MyRedTextAppearance</item>
<style name="MyRedTextAppearance" parent="@android:style/TextAppearance">
<item name="android:textColor">#F00</item>
<item name="android:textStyle">bold</item>

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=""
android:text="This is red, isn't it?"

For more referense click here

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

Related post

Copyright (C), All Rights Reserved.

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