<tablelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:stretchColumns="1"> <TableRow> <!-- Column 1 --> <TextView android:id="@+id/tbl_txt1" android:layout_width="0dip" android:layout_height="wrap_content" android:background="@color/red" android:textColor="@color/white" android:padding="10dip" android:layout_margin="4dip" android:layout_weight="1" android:text="Column 1" /> <!-- Column 2 --> <TextView android:id="@+id/tbl_txt2" android:layout_width="0dip" android:layout_height="wrap_content" android:background="@color/red" android:textColor="@color/white" android:padding="10dip" android:layout_margin="4dip" android:layout_weight="1" android:text="Column 2" /> <!-- Column 3 --> <TextView android:id="@+id/tbl_txt3" android:layout_width="0dip" android:layout_height="wrap_content" android:background="@color/red" android:textColor="@color/white" android:padding="10dip" android:layout_margin="4dip" android:layout_weight="1" android:text="Column 3" /> </TableRow> </TableLayout>
Tuesday, October 12, 2010
TableLayout columns equal width
Subscribe to:
Post Comments (Atom)
Best of the best! You do not know how many people are searching for this! Thanks a lot.
ReplyDeleteHappy I could help!
ReplyDelete- tk
nice one....
ReplyDeletePerfect! width=0 and weight=1 did the job. Also without stretchColumns="1".
ReplyDeleteMany thanks
Hans
thanks a million !!! Been Stuck on this layout problem for awhile...I had try many combinations with nested layouts...
ReplyDeleteThanks a lot...
ReplyDeletethis seems to only work if the text in the TextViews is the same width. if not, the table does fill the width of the view, but the column widths seem to be proportional to their contained text widths (if that makes any sense :-) )
ReplyDeleteThat is great !!! Thx
ReplyDeleteThank you!
ReplyDeleteVery helpful, thanks!
ReplyDeletethanks i quest time...
ReplyDeleteI just use this tip!
ReplyDeleteThanks a lot!!!
Works perfect... Thanks a lot... :)
ReplyDeleteWow... this is grate. lot of problems solved. Thanks a lot
ReplyDeleteyes really nice one !!! :)
ReplyDeletethx man... that is exactly what I was looking for! :)
ReplyDeleteI came to say thanks!
ReplyDeleteHi
ReplyDeleteAm creating Textview in Runtime. For this i need to set the columns width as fixed one. i don't have have any Textview inside my table layout
TableRow tR = new TableRow(this);
//adding textViews to each Table cell
TextView tV_txt1 = new TextView(this);
TextView tV_txt2 = new TextView(this);
TextView tV_txt3 = new TextView(this);
for this how can i fix the width..?
Thanks for the nice tutorial man... Even this
ReplyDeletehttp://www.compiletimeerror.com/2013/07/android-tablelayout-example.html might help, have a look...
This is simple but a guaranteed treasure!
ReplyDeleteI have text views with borders. So when I do this, there are jagged borders.....how do i solve that
ReplyDeleteTake a bow Master!
ReplyDeleteAmazing. Thanks so much!!
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThanks a lot!
ReplyDeleteExcellent......... post..... Thanks... a lot.. It helped me very much...
ReplyDeleteCheck out my blog. The following post includes a video that shows you how to create an Android smartphone application that displays a vertically scrolling list of countries on the screen. The application is created using the Eclipse IDE and Android SDK. It features an “OK” button at the bottom of the screen that, when pressed, terminates the application.
ReplyDeleteIn the process of making this Android application you will encounter the following SDK object types, etc:
• ScrollView,
• Button,
• View,
• TableLayout,
• TableRow,
• OnClickListener,
• TextView,
• Colours in Android represented by hexadecimal numbers.
http://androidprogrammeringcorner.blogspot.com/2015/03/pak-longs-android-programming-corner.html
Best regards,
Philip
thanks dude ! you save my life !
ReplyDeleteThank you so much for this! It's perfect!
ReplyDeleteAwesome. Thanks. Worked perfectly for me :)
ReplyDeleteThanks.
ReplyDeletewas stupid enough to invoke a relative layout inside table row and gave layout_weight.never knew that layout weight works in tablerow
Thanks a ton
Thanks God! You saved my life man!
ReplyDeleteThanks Man You Saved
ReplyDeleteThank yo so much.
ReplyDeleteThis is too good.
ReplyDeleteMarketing articles leverage persuasive language Employer Tracked VPN and storytelling techniques to influence consumer behaviour and promote products or services.
ReplyDelete