Home > Software engineering >  Hiding and repositioning views programatically
Hiding and repositioning views programatically

Time:01-07

I have a fragment where I want to hide and reposition a few textviews and imagebuttons programatically in case they are empty but I also want to put the other two that are below them, on top of the screen where those were in the first place.

.setTop doesnt seem to do move the view

`if (tr.getName().isEmpty()) {
        tv1.setVisibility(View.INVISIBLE);
        tv2.setVisibility(View.INVISIBLE);
        imgb1.setVisibility(View.INVISIBLE);
        tv3.setVisibility(View.INVISIBLE);
        tv4.setVisibility(View.INVISIBLE);
        imgb2.setVisibility(View.INVISIBLE);
    }`

I make those invisible but how do I set the other components on top of the screen, basically on top of those that are invisible?

CodePudding user response:

You should use: view.setVisibility(View.GONE)

instead : view.setVisibility(View.INVISIBLE)

  • Related