P
P
prosto_anton2016-04-17 12:58:55
Android
prosto_anton, 2016-04-17 12:58:55

How to make an element visible in Android?

The element that extends the LinearLayout contains a number of elements (ImageButton), some of which are hidden. Changing the coordinates of these elements is done by calling the setX method. The problem is that elements that are initially hidden are not visible when the x coordinate changes, although they are in the visible area. With elements that are initially visible, there is no such problem.
Please explain the essence of the problem and describe how to deal with it.
PS:
There were also problems with the sizes of initially hidden elements, but they were solved by calling the measureChildren(getWidth(), getHeight()) method on the container element.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2016-04-17
@FAQEnD

Have you tried it like this?

ImageButton imageButton = (ImageButton) findViewById(R.id.id_of_image_button);
imageButton.setVisibility(View.VISIBLE);

And in general, you can not hide the buttons behind the screen, but simply place them in the right place, but at the same time assign them View.GONEand they will be invisible, and they won’t take up space, but at the right time already useView.VISIBLE

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question