Android TableLayout Format - android

So I have a table layout that Im adding rows to through code since its not a constant table or a constant amount of rows. The problem Im having is right now my last column isnt fitting all the text because the middle row is set to stretch and its taking up most the view. Is there a way to set weights for the columns so that I can have the one row be bigger than the rest but still show everything else.

The problem Im having is right now my last column isnt fitting all the text because the middle row is set to stretch and its taking up most the view.
Then either change it so the last column is the stretch column, or list both (e.g., android:stretchColumns="1,2").
Is there a way to set weights for the columns so that I can have the one row be bigger than the rest but still show everything else.
By listing more than one in android:stretchColumns, the stretching effect is applied equally to all. You can think of this as the columns having equal weight.

Related

android grid view set column width

I am having trouble controlling the size of the columns in my
GridView.
The first column is only 3-4 chars and the other 4 columns
are 5-8 chars.
For some reason, all the columns are the same width,
leaving a huge amount of spacing after the first column and wrapping
the text inside the others.
Is there a way, I can set the width of
individual columns in the grid view?
In an ideal world, gridview
would work like an html table, where the smaller columns are shrunk to
fit the data and larger columns expand as necessary.
Any ideas would
be helpful

GridLayout vs TableLayout

I'm unsure as to what the differences between the two of them are and which I should use for my purpouses?
What I'm trying to do is create a custom virtual numpad with text inputs and that can dynamically change its contents to have a date picker.
So I need a layout system which supports many different sized cells inside it.
Which better suits my needs and what's the difference?
In my experience I had both GridLayout and TableLayout give me the same results. They both seem to stretch the columns to fit the widest child element. Neither will give you gird lines or borders around the cells.
From the official docs on GridLayout:
Row and Column Specs
Children occupy one or more contiguous cells, as defined by their rowSpec and columnSpec layout parameters. Each spec defines the set of rows or columns that are to be occupied; and how children should be aligned within the resulting group of cells. Although cells do not normally overlap in a GridLayout, GridLayout does not prevent children being defined to occupy the same cell or group of cells. In this case however, there is no guarantee that children will not themselves overlap after the layout operation completes.
and from the TableLayout:
The table has as many columns as the row with the most cells. A table can leave cells empty. Cells can span columns, as they can in HTML.
So it seems to me that the GridLayout is a bit more versatile and probably what you are looking for.

Dynamically aligned Variable Sized cells in a Layout

What I have to do is draw variable size cells from left to right. Since the data is from server, its length can't be determined (thus the need for variable sized cells.). I have tried the gridviews, tablelayouts but they align them in an order. What I want is something like this:
a sample http://img18.imageshack.us/img18/4136/samplejy.png
the most important thing is they are kind of aligned in a column (though one column can have further multiple columns) but there is no row as such..the cells are in some kind of array which I have to align from left to right and not from top to bottom.. If anyone has tried anything like this it will be very helpful.. thanks

Android ListView ellipsize wide column content

I have a ListView that shows 2 columns per row. I don't have any specific column layout XML so Android is determining it for me. If the text in the 1st column is too wide then bad things happen to the layout of the 2nd column. Ideally I want Android to ellipsize the text in the 1st column at a sensible width and/or restrict the 1st column's width to 80% of the total displayable width. Can I do this in code?
Am happy to ellipsize the column 1 text itself manually when setting up the ListView if that's simple but it would have to cope with orientation changes (because in landscape the column 1 text would not be so wide as to have to ellipsize).
Thanks.
Set the width of your textviews to a specific width, ie, 50dp instead of wrap_content.
Then set ellipsize to true.
The rest should take care of itself.

Table row wider than phone width

I have a TableRow with a decent amount of text in one of the columns. This text causes the table to be wider than the width of the phone, and so the right side of the data is cutoff.
I would like to wrap the text to the next row, but I can't tell how to do this. I tried setting singleLine="false", but that doesn't seem to do anything. Alternatively, I would be ok truncating the data, but there doesn't seem to be a great way of doing this either.
I ended up using a LinearLayout instead of a TableLayout. This does wordwrap by default and is close enough to TableLayout for my use.

Categories

Resources