Filip V
Filip V

Reputation: 435

Android half screen activity

I want to create activity with one button. When you click on the button, half screen layout appears from bottom. enter image description here

And more when you click on background layout, new front background disappear.

Do you have an idea who to implement this? Thanks in advance.

EDIT:

I have found solution for this feature. Firstly, I make new hidden view below the screen( You can found how from the answers below).

And then, I animate on button click with the following code:

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

Upvotes: 1

Views: 2486

Answers (1)

Maciej Sikora
Maciej Sikora

Reputation: 20142

<?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>

To show hide content change it marginBottom. In start marginBotton should be - of this layout height to be out of screen. You can do it using animation on translateY and on end change marginBottom to finish value. This is one of possible solutions.

Upvotes: 2

Related Questions