你如何进行动态布局?

时间:2022-05-27 13:13:08

I want to dynamically hide/show controls in an activity based on a button touch event: when the user presses the "details" button, I want to show more controls in the same activity.

我想基于按钮触摸事件动态隐藏/显示活动中的控件:当用户按下“详细信息”按钮时,我想在同一活动中显示更多控件。

What is the best way to handle this? Is there a way to do TextView.Hide()? Can it animate the transition?

处理这个问题的最佳方法是什么?有没有办法做TextView.Hide()?它能否为过渡做好准备?

1 个解决方案

#1


9  

setVisibility() will allow you to make a widget visible, invisible, or gone. The difference between the latter two is that an invisible widget still takes up space, while a widget that is gone does not.

setVisibility()将允许您使窗口小部件可见,不可见或消失。后两者之间的区别在于,不可见的小部件仍占用空间,而已消失的小部件则不占用空间。

Android has an entire animation framework for slides, fades, spins, and the like. Here are two sample projects showing some of this.

Android有一个用于幻灯片,淡入淡出,旋转等的完整动画框架。以下是两个展示其中一些的示例项目。

#1


9  

setVisibility() will allow you to make a widget visible, invisible, or gone. The difference between the latter two is that an invisible widget still takes up space, while a widget that is gone does not.

setVisibility()将允许您使窗口小部件可见,不可见或消失。后两者之间的区别在于,不可见的小部件仍占用空间,而已消失的小部件则不占用空间。

Android has an entire animation framework for slides, fades, spins, and the like. Here are two sample projects showing some of this.

Android有一个用于幻灯片,淡入淡出,旋转等的完整动画框架。以下是两个展示其中一些的示例项目。