android:动态布局?
我试图在列表视图的顶部有一个搜索框。但我希望这个搜索框有时消失,并且列表视图调整大小以重新获得空间。有没有一种方法可以在不重新加载另一个不同布局的情况下做到这一点???
有没有办法在当前视图中添加和删除组件?我一直在使用 setvisibility 但它不会调整任何内容的大小。
如果您知道,请给出代码示例! :)
Im trying to have a searchbox on the top of my list view. But I want this searchbox to disapear sometimes and the listview to resize to regain space. Is there a way I can do that without reloading another and different layout ???
is there a way to add and remove a component from the current view ?I have been playing with setvisibility but it doesnt resize anything.
Please, if you know, give code example ! :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用这样的布局做到了这一点
然后,在代码中,执行以下操作:
释放空间,或
显示搜索框。
除了 EditText 之外,还可以使用任何其他单个控件或控件组合的布局。
将其可见性设置为 GONE 将使周围的 editFrame 布局(也可以是 FrameLayout)缩小到零大小并回收 ListView 的空间(设置为直接位于 editFrame 布局下方的布局)。
I did this with a layout like this
Then, in the code, do the following:
to free up the space, or
to show the search box.
Instead of the EditText, one can as well use any other single control or a layout for a combination of controls.
Setting its visibility to GONE will make the surrounding editFrame layout (can as well be a FrameLayout) shrink to zero size and reclaim the space for the ListView (which is set to be layout directly below the editFrame layout).