There is an NxN matrix, and I need to fill it in descending order in a spiral from the first element (the numbers containing “6” are not displayed) Example: enter image description here

How can I fill such a table in Android, if each element should be displayed in a spiral after a short delay? What should I use? The only solution I could think of so far is to programmatically create a TextView in a loop and transfer the value of the number that the matrix element should fill into the setText () method and place it under the previous TextView — if we go down, to the right of the previous — if we go to the right and so on But something tells me that there must be a more beautiful and correct way to do it.

The matrix can be N = 0 to 1000 (matrix size: NxN) - how to implement such a large matrix on the screen of a smartphone? Maybe use ScrollView in both directions or some scaling?

  • Initially, you just need to get a List of values, sorted by a special algorithm. Look here geeksforgeeks.org/ ... You will have to refactor a bit. But it is not difficult. There is no need to create a textView dynamically here, just put the ready sheet in the gridView, or in the recyclerView with the GridLayoutManager, which has columnNumber equal to the value of your specified n. - Android Android
  • Yes, but how can I set the order in which items are displayed? Write Custom Layout Manager, where to set the order of drawing elements? Are there any examples of this approach? - Vova Medvedev

0