是否可以从屏幕上删除(滑下)视图?Android的

Tar*_*ras 1 user-interface android android-layout

是否可以从屏幕中删除视图?Android的

例如,我有一些布局,其中包含3个布局;

layout_1 layout_2 layout_3
Run Code Online (Sandbox Code Playgroud)

是否可以单击layout_1,并将其从屏幕移开,您将收到可见信息

layout_2 layout_3
Run Code Online (Sandbox Code Playgroud)

提前致谢.

upd:问题是,我需要顺利地滑下这个视图.看起来像Facebook的侧边栏.但另一件事是,删除layout_1后的其他两个布局应该被拉伸以适应父布局.

Doo*_*ght 5

将视图设置为id.

然后做

(LinearLayout) linLayout = (LinearLayout) findViewById(R.id.layout_1);
linLayout.setVisibility(View.GONE);
Run Code Online (Sandbox Code Playgroud)

(将它投射到它所输入的内容.)

或者直接用:

findViewById(R.id.layout_1).setVisibility(View.GONE);
Run Code Online (Sandbox Code Playgroud)

编辑:关注您的新信息和我评论的问题/答案:

(LinearLayout) linLayout = (LinearLayout) findViewById(R.id.layout_1);
Animation animation = new TranslateAnimation(0, 500,0, 0); //May need to check the direction you want.
animation.setDuration(1000);
animation.setFillAfter(true);
linLayout.startAnimation(animation);
linLayout.setVisibility(View.GONE);
Run Code Online (Sandbox Code Playgroud)

如果你希望其他2也逐渐占用空间,你可能需要更高级的东西.