Table row wider than phone width - android

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.

Related

Android TableLayout Wrap Text issues

My tablelayout displays a bunch of values that are random and is created programatically.
The issue I am having is that because I don't know the content that'll be displayed on the table I am not able to use setColumnShrinkable(index, true) and therefore since the table is big, some of the columns would get cut off and not show.
I've tried playing with mTableLayout.setShrinkAllColumns(true); but that would result in columns that shouldn't shrink to shrink and thereby making the wrapping of the texts formatted poorly (see image below) and also the height of each column is too large.
I've also tried playing with minWidth of the columns but that doesn't seem to be doing anything.
What would be the best wayt to tackle this issue? Thanks!

Android TableLayout Format

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.

Table layout only as wide as first image?

I'm building an Android app, and using a TableLayout ViewGroup to display my data.
I would like the TableView to occupy the entire width of the screen, however I'm having trouble getting this to work.
What seems to happen, is the table is only as wide as the widest element in the table, in this case, the image that I put in it.
Here's a screenshot to illustrate the problem.
Additionally, here's the XML source code of my layout.
What specifically should I do to have the layout stretch to the entire width of the screen?
Thanks in advance!
You only have 1 column. Therefore, it should be stretchColumns="0".
Creating a single-column TableLayout is pointless and wasteful. Use a vertical LinearLayout, please. You will probably find that it works better with respect to your problem as a side benefit.
Also, do not repeat the xmlns:android="http://schemas.android.com/apk/res/android" -- it only needs to go on the root element.
BTW, columns are indexed starting from 0, so you are stretching a non-existent column in your existing TableLayout.

Format buttons to fill parent based on dynamically added text

I'm hoping I can get some formatting help. I have a TableLayout. Inside the TableRow, I have 2 RelativeLayouts. Each RelativeLayout has 2 buttons in it that overlap (this is by design). The button text is dynamically added at runtime. This makes the buttons taller if the text is long enough. However, the text in one column (RelativeLayout) is different that the text in other column (RelativeLayout). So, the TableRow is expanded by the taller of the buttons. What I'd like is to have the smaller buttons fill in to the same size as the larger one.
I'm real new to Android development, but I've tried every combination of match_parent/fill_parent/wrap_content that I can think of, but none of them make the buttons stay the same size (that is, the size of the larger one). Some even expand the button to the full height of the screen (which I don't understand either...I'd think that the parent would be the TableRow and that would limit it)...
I appreciate any advice.
Use
button.setEllipsize(TruncateAt.END);
attribute while creating the buttons

Two columns of autowrapped text

I need to lay out several (for example, two) labels (textviews) as columns. The texts can be longer altogether than one screen line and may not contain line breaks, so they need to be formatted (wrapped) to fit the screen width.
I can arrange labels as columns if they are shorter altogether than a screen line. I can wrap a text to fit the screen if there’s only one column. But if the texts are longer and there are more than one column, I cannot achieve what I want, because the first column always fills the whole screen width.
I tried to do this via xml-markup. I tried a lot of markups using LinearLayout, TableLayout and RelativeLayout. All didn’t work. Maybe, I didn’t use them properly.
I can imagine the ways using code to manually calculate views’ widths, but haven’t tried. Any solution is welcome, but using markup only are preffered.

Categories

Resources