setVisibility(GONE) view becomes invisible but still occupies space

后端 未结 13 1967
我在风中等你
我在风中等你 2020-12-03 03:56

I\'ve got a view that is effectively is a button. Here is its XML layout (add_new.xml)




        
相关标签:
13条回答
  • 2020-12-03 04:58

    This is an Android bug in my opinion, we just fix this issue doing this:

    <FrameLayout android:layout_width="match_parent"
        android:layout_height="wrap_content">
    
        <LinearLayout android:id="@+id/layout_to_hide"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content">
             //Put here your views
        </LinearLayout>
    </FrameLayout>
    

    Just hide LinearLayout with id LAYOUT_TO_HIDE with Visible.GONE and then root FrameLayout will collapse its height giving you a "hidden" with non-blank-space header.

    0 讨论(0)
提交回复
热议问题