Android: Have an arbitrary View slide under another View like the software keyboard does
Asked Answered
G

2

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?

Gormandize answered 13/2, 2010 at 22:49 Comment(0)
R
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.

Raw answered 14/2, 2010 at 12:32 Comment(3)
Wow, that was much much easier than I expected. Thank you very much!Gormandize
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...Wingover
@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.Raw
B
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

Biosphere answered 29/1, 2016 at 20:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.