Android Table Layout with columns of equal width
Tutorial by Stefan Trost | 2013-09-25 at 15:03
Today, I would like to show you a possibility of how to design an XML Table Layout for Android with columns of the same width.
The key lies in the specifications layout_width="0dip" and layout_weight="1". In the following example, we have three columns with the same width containing a TextView:
<tablelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:stretchColumns="1"> <TableRow android:id="@+id/tableRow1" android:layout_height="wrap_content" android:layout_margin="10dp" > <!-- Column 1 --> <TextView android:id="@+id/textView1" android:layout_height="wrap_content" android:layout_width="0dip" android:layout_weight="1" android:text="Column 1" /> <!-- Column 2 --> <TextView android:id="@+id/textView2" android:layout_height="wrap_content" android:layout_width="0dip" android:layout_weight="1" android:text="Column 2" /> <!-- Column 3 --> <TextView android:id="@+id/textView3" android:layout_height="wrap_content" android:layout_width="0dip" android:layout_weight="1" android:text="Column 3" /> </TableRow> <!-- more rows <TableRow ... </TableRow> --> </TableLayout>
You can add more rows by copying and editing the TableRow section from "<TableRow" to "</TableRow>" to the commented part "more rows".
About the Author
You can find Software by Stefan Trost on sttmedia.com. Do you need an individual software solution according to your needs? - sttmedia.com/contact
Show Profile
Related Topics
Fonts for Windows, Linux and Mac on the Web
Article | 0 Comments
Android Splash Screen Tutorial
Tutorial | 0 Comments
The Secure Password
Info | 0 Comments
10 powerful and helping Tips regarding the Yo-Yo-Effect
Tip | 0 Comments
MySQL: 3 Ways of showing Table Definition and Structure
Info | 0 Comments
jQuery: Assign Action to Keyboard Keys (Keyboard Event)
Tip | 0 Comments
XAMPP: How to set up SSL/HTTPS for local Projects
Tutorial | 4 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.