11

I want to have a View pop in at the bottom of the page exactly like the software keyboard view does in the compose section of the Mms app. It slides in from the bottom, as if it's being added to a vertically oriented LinearLayout, only making the ListView smaller. It becomes a part of the current layout instead of popping up over the top of it. I'd like to to this exact thing with my own custom View.

Does the question make sense at all?

synic
  • 26,359
  • 20
  • 111
  • 149

2 Answers2

18

Sure it makes sense!

I have a SlidingPanel demo that demonstrates the general technique. It's a bit more complicated than it needs to be, since it implements a custom View class.

The gist is you actually have your panel in the layout to begin with, positioned where you want it to be, but you set android:visibility="gone" so it doesn't appear. When you want it visible, make it visible and set up a TranslateAnimation to slide it in.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Wow, that was much much easier than I expected. Thank you very much! – synic Feb 15 '10 at 05:38
  • Is it possible to add that view programmatically? I'd like to use it in different activities and wonder if I need to place it in every layout in preparation... – Sven Menschner Sep 19 '12 at 07:46
  • @SvenMenschner: You would need to add a single-argument constructor to supply the `Context` and add a setter for speed for it to be usable outside of a layout file. – CommonsWare Sep 19 '12 at 10:44
0

Today there is a SlidingLayout view to use as explianed in this question.

Just use this lib and add the following in your layout:

<com.wunderlist.slidinglayer.SlidingLayer
xmlns:slidingLayer="http://schemas.android.com/apk/res-auto"
android:id="@+id/slidingLayer1"
android:layout_width="@dimen/layer_width"
android:layout_height="@dimen/layer_height"
slidingLayer:shadowDrawable="@drawable/sidebar_shadow"
slidingLayer:shadowSize="@dimen/shadow_size"
slidingLayer:offsetDistance="@dimen/offset_distance"
slidingLayer:previewOffsetDistance="@dimen/preview_offset_distance"
slidingLayer:stickTo="top|bottom|right|left"
slidingLayer:changeStateOnTap="true">

and add the following to your gradle build file:

compile 'com.wunderlist:sliding-layer:1.2.5'

You can download a demo app from here

Community
  • 1
  • 1
Jan Seevers
  • 768
  • 1
  • 11
  • 20