N
N
Nikita2017-09-28 21:00:41
Java
Nikita, 2017-09-28 21:00:41

How to make a textview randomly appear on the screen?

There is a file in which the text was written line by line (n-number of lines ..). Each row is added to the ArrayList.
Task: take a string from an array and put it in a textview. The TextView should appear randomly within the screen. What are the methods for managing textview on the screen. And how to create them (textview widgets) a lot like components in a listView.
The question is quite interesting, maybe someone has similar projects in mind

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Myvrenik, 2017-09-28
@gim0

The task is not interesting, rather banal to the limit :) You need some kind of FrameLayout, in which, using the #addView method, you insert the TextView created in the code and change the absolute XY coordinates.

FrameLayout frameLayout = findViewById(R.id.frame);
TextView textView = new TextView(getContext());
frameLayout.addView(textView);

// С помощью класса Random сгенерируй случайные координаты в пределах
// доступного пространства на экране
textView.setX(100);
textView.setY(100);

The code was written from the head in order to convey the idea, not to provide a complete solution.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question