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

前端 未结 2 1147
我在风中等你
我在风中等你 2020-12-30 07:34

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

相关标签:
2条回答
  • 2020-12-30 08:09

    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

    0 讨论(0)
  • 2020-12-30 08:32

    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.

    0 讨论(0)
提交回复
热议问题