-9

How onDraw() method works when we set view's visibility in Android?

Eg. When we declare a view as visibility:gone in xml or setvisibilty to View.GONE in java. What happens at the backend? Does it call onDraw() method if we declare a view as visibility GONE?

My main question is what happens in the Android backend when we declare view as VISIBLE, GONE, INVISIBLE, does it call onDraw() method?

Nishant Tanwar
  • 383
  • 4
  • 8
  • 18

2 Answers2

1

View.GONE

This view is invisible, and it doesn't take any space for layout purposes.

This view is invisible, and it doesn't take any space for layout purposes. Use with setVisibility(int) and android:visibility.

View.INVISIBLE

This view is invisible, but it still takes up space for layout purposes. This view is invisible, but it still takes up space for layout purposes. Use with setVisibility(int) and android:visibility.

for information please read from doc.

Community
  • 1
  • 1
AskNilesh
  • 67,701
  • 16
  • 123
  • 163
0

this might help to answer your question
please note that there is differnce in View.Gone and View.Invisible

import android.support.v7.app.AppCompatActivity; import android.os.Bundle;

    public class Demo extends AppCompatActivity {
     private RelativeLayout layoutfortexttopSelfView;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_wi_fi_demo);

     layoutfortexttopSelfView.setVisibility(View.GONE); //this will hide the view 

layoutfortexttopSelfView.setVisibility(View.Visible); //this will unhide the view 

//this will invisible and  visible the view  

    layoutfortexttopSelfView.setVisibility(View.INVISIBLE);
        layoutfortexttopSelfView.setVisibility(View.Visible);

        }
    }

when we do view.gone the layout gone hide and the layout constrains get adjusted as per the things which is still visible in the screen but when we do INVISIBLE, the layout doesnt disappear , its present in the xml but not visible , then in that case the layout doent disturb . Hope this might help please ask if i am not clear .

Arun Yadav
  • 203
  • 3
  • 9