Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement a sliding up a view (like news feed in facebook app)

Tags:

android

view

I am not sure how to do this? I want a static view at the bottom of another layout that the user can slide up to show another view. I'm not sure what this feature is called but I know the Facebook app does this and so does ESPN and Google plus. Thanks!

like image 431
thunderousNinja Avatar asked Jan 20 '23 02:01

thunderousNinja


1 Answers

The simplest thing to use would be a SlidingDrawer.

As long as you want to slide up from the bottom (or the right) this will work beautifully. It doesn't work if you want to slide something down from the top or in from the left however.

To use it you just need something like this in your XML layout:

<SlidingDrawer
android:id="@+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:handle="@+id/handle"
android:content="@+id/content">

    <ImageView
    android:id="@id/handle"
    android:layout_width="88dip"
    android:layout_height="44dip" />

    <GridView
    android:id="@id/content"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

</SlidingDrawer>

Where the ImageView is the "handle" (the thing you drag up and down to open the drawer) and the GridView is the whatever content you want the drawer to hold (It can be any type of view, not just a GridView).

like image 77
theisenp Avatar answered Jan 29 '23 22:01

theisenp