2016-07-14 49 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,然後爲第二個/上方視圖執行後向動畫。 –