android-sliding-layer-lib icon indicating copy to clipboard operation
android-sliding-layer-lib copied to clipboard

Slide partially feature.

Open jltserenity opened this issue 10 years ago • 3 comments

How can I open the SlidingLayer partially so that it only shows 50% or 70% of its View on the screen. Im talking about something similar in the GoogleMaps app in which when a POI is clicked a layer opens but it still shows a marker on top. Thanks !

jltserenity avatar Jan 28 '14 06:01 jltserenity

Hi @jltserenity ,

you can set the width and height of your slidinglayer setting the LayoutParams of it as you can se we don in the example app.

An example of the slidinglayer coming from the bottom (located in the sample app MainActivity.java file):

       // Sticks container to right or left
       LayoutParams rlp = (LayoutParams) mSlidingLayer.getLayoutParams();
       ................
       ................
       else if (mStickContainerToRightLeftOrMiddle.equals("bottom")) {
            textResource = R.string.swipe_down_label;
            d = getResources().getDrawable(R.drawable.container_rocket);

            mSlidingLayer.setStickTo(SlidingLayer.STICK_TO_BOTTOM);
            rlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
            rlp.width = LayoutParams.MATCH_PARENT;
            rlp.height = getResources().getDimensionPixelSize(R.dimen.layer_width);
       ................
       ................

if you look at the two last lines (rlp.width and rlp.height) here you can set the maximum size of your slidinglayer in terms of width and height.

So now is your turn to play with this :-)

CesarValiente avatar Aug 22 '14 16:08 CesarValiente

Hello @jltserenity There's no exposed way to do this right now on SlidingLayer. Nevertheless the current implementation doesn't need many adjustments to achieve that behavior. Generally speaking you need one more state (OPEN, PARTIALLY_OPEN, CLOSED) and an offset for the partial state. See https://github.com/6wunderkinder/android-sliding-layer-lib/blob/master/Library/src/com/slidinglayer/SlidingLayer.java#L379

Feel free to progress ahead on that and share and share any issue.

JlUgia avatar Aug 23 '14 13:08 JlUgia

@CesarValiente hello, I had same problem on the sample code ,when I selected Stick layer to Bottm. I setted the rlp.height =100 or other, the layer always on full screen... thx : ))

WilliamLuoKnife avatar Jun 01 '17 08:06 WilliamLuoKnife