enter image description here

How to get the size marked in red in order to assign them to the Header which is marked in green when displayed?

It is necessary that the Header text is green blocks with the same width as the red ones. As in Excel spreadsheet or SQL.

  • 3
    Well, give them the same width in the markup and you will be happy. Don't wrap_content for columns to use. - xkor
  • @xkor, and how to find out how much you need to specify? After all, on different phones it will be displayed differently - Andro
  • one
    As much as you need to display the content you need in an adequate size. The width of the phones is not so much different. Minimum 320dp, most 360dp, less than adequate maximum 480dp. You can also set not a hard size, but set the weight columns using the layout_weight attribute. - xkor
  • 2
    I wrote an example to you yesterday, did you not have time to read it? Just create any markup, specify the parameters of the ratio of the weight layout_weight, center, set the same indents and so on. it is a pity that the correct answers are removed ((( - Shwarz Andrei
  • @xkor, but is it correct to indicate the size in numbers ?, they say this is a bad code - Andro

1 answer 1

Summarize the comments:

You do not need to get the size of the red blocks and set them programmatically green blocks. You need to set the same size (width) for the red and green blocks in the markup (xml). Either through shares (weights in LinearLayout), or directly in dp .

Regarding the correctness of the indication of the size of the numbers ... I do not know where you heard such nonsense that it is bad, although perhaps you pulled this statement out of the context in which it made sense. Poorly indicate the size of the numbers where logically the size should depend on the content. It is bad to NOT specify the size in numbers where it should NOT depend on the content. The width of the columns should be specified either in fractions (weights) or in fixed figures, possibly different for several screen reference sizes. On my current project, for example, there is a table with the results of races; two markup is used there: portrait and landscape. And 4 sizes (dimensions) of columns: phone in portrait orientation, phone in landscape, tablets with a small screen (7-9 ") and tablets with a large screen (tablets only in landscape). This is quite enough for a normal appearance on all devices .