Not getting RelativeLayout's getHeight() after setting Visibility Visible from Visiblity GONE

后端 未结 4 919
醉话见心
醉话见心 2021-01-15 04:57

What i want is, when i click on Dashboard Button it will open like a SlidingDrawer and after it opened when clicked on it again it will close. i use this custom drawer becau

4条回答
  •  春和景丽
    2021-01-15 05:26

     //don't put gone in xml
    

    In OnViewCreated look for the height and after that make this view GONE

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
             relLayTwo = (RelativeLayout) findViewById(R.id.relLayTwo);
             mHeight = relLayTwo.getHeight();
             relLayTwo.setVisibility(View.GONE);}
    

    In this way you will get the height because on onViewCreated the view is already drawn, and after you have what you need, make the view GONE.

提交回复
热议问题