2016-07-14 91 views
0

我想用一个按钮创建活动。当你点击按钮时,屏幕底部会出现半屏布局。 enter image description hereAndroid半屏活动

更多当你点击背景布局时,新的前台背景消失。

你知道谁来实现这个吗? 在此先感谢。

编辑:

我已经找到了此功能的解决方案。 首先,我在屏幕下方制作新的隐藏视图(您可以从下面的答案中找到答案)。

然后,我对动画按钮单击用下面的代码:

dialog.animate().translationY(-HEIGHT).setDuration(TIME); 
+0

我建议使用一个视图(任何一种你认为最适合其内容的视图)和一个使它离开屏幕的translationY值。那么你可以使用valueanimator或类似的东西来平滑地上下移动,并用你想要的输入触发它们 – kimchibooty

+0

你能否给我提供一些更详细的说明,如何在屏幕外设置视图以及谁来从底部设置动画? –

+0

这个问题很少或根本没有努力。 – basic

回答

1
<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 

android:layout_width="match_parent" 
android:layout_height="match_parent" 
> 
<!-- view with button --> 
<LinearLayout 
    android:id="@+id/task_list_fragment" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    > 
</LinearLayout> 

<!-- example content hided in bottom --> 
<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="@dimen/height_of_your_content" 
    android:layout_alignParentBottom="true" 
     android:layout_marginBottom="@dimen/minus_height_of_your_content" 
    > 
</LinearLayout> 
</RelativeLayout> 

要显示隐藏的内容更改marginBottom。在开始marginBotton应该是 - 这个布局高度在屏幕外。您可以在translateY上使用动画并在结束更改marginBottom上完成值。这是可能的解决方案之一。

+0

如何检测点击背景层? –

+0

将其设置为id和findElementById并设置OnClickListener,然后为第二个/上方视图执行后向动画。 –