Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make the scrolling panel's background (child 1 of sliding's panel) transparent? #6

Closed
dor506 opened this issue Jul 8, 2013 · 12 comments
Labels

Comments

@dor506
Copy link

dor506 commented Jul 8, 2013

Hey!

First of all good job!
👍

I'm trying to achieve something like this:
http://www.gru.at/android/wp-content/uploads/2010/09/s_close.png
http://www.gru.at/android/wp-content/uploads/2010/09/s_open.png

my xml is like that (I Hope you'll understand :|)

RelativeLayout

SlidingPanel

RelativeLayout (The main content)
RelativeLayout
LinearLayout background=#00000000 (which I try to make transparent)
#ImageView background="up_arrow"
LinearLayout

SlidingPanel

RelativeLayout

However, the linearlayout's backgorund is always white

If I try to make it red, blue, brown, etc.. it works!
but transparent doesn't work

It seems like there is a permanent white background somewhere there in the back

I need your help, thanks in advance! :)

@tokudu
Copy link
Contributor

tokudu commented Jul 8, 2013

By default, the sliding content part doesn't overlap the main content. The main content actually has a bottom margin of the height of the sliding panel. So what you are seeing is the white background of your outer relative layout - try changing that.

@josomers
Copy link

Can someone provide an example? I can't figure this out. I get a solid background color for my dragger view, but transparency won't work...

@felipe-silvestre-morais

I have the same problem. I tried change to transparent color all views, but didn't work.
When fixed, please let me know.

@MrXo
Copy link

MrXo commented Aug 14, 2013

A sample would indeed be very helpful.

Is the manipulation of the view margin part of the DragViewHelper or do you manually calculate the bounds of the main view?

@tokudu
Copy link
Contributor

tokudu commented Aug 14, 2013

Post your layout, it would be easier to notice what you are doing wrong.

The bounds of the main view are manually calculated based on the height of the sliding panel.

@MrXo
Copy link

MrXo commented Aug 16, 2013

Based on your hint I fixed it myself. For everyone interested in drawing behind the slider, simply change the protected boolean drawChild(final Canvas canvas, final View child, final long drawingTime) method to not clip the bounds of the canvas:

if (!mDrawBehind && mCanSlide && !lp.slideable && mSlideableView != null) {
            // Clip against the slider; no sense drawing what will immediately be covered.
            canvas.getClipBounds(mTmpRect);
            mTmpRect.bottom = Math.min(mTmpRect.bottom, mSlideableView.getTop());
            canvas.clipRect(mTmpRect);
            if (mSlideOffset < 1) {
                drawScrim = true;
            }
        }

The new mDrawBehind variable allows to always draw the background when set to true.

@ShakeJ
Copy link

ShakeJ commented Sep 4, 2013

Thanks you for your open Source!

Have a plan support 'Transparent'?

********* I reslove.
in XML, layout Backgorund transparent color change,
I edit slidingUpPanelLayout.java
protected boolean drawChild(Canvas canvas, View child, long drawingTime)

canvas.clipRect(mTmpRect); <~ this line delete
And Trasparent well. Thanks.

@sagarwanojwar01
Copy link

Hi I have commented the line
canvas.clipRect(mTmpRect); in my code, but the layout bcomes transparent only when its expanded.

When the layout is collapsed it is not transparent.

I have modified the code so that the panel slides to 0.5f. i.e half of the screen

Why so???

Please refer the images.
Thanks in Advance.
screenshot_2013-10-10-10-09-47
screenshot_2013-10-10-10-09-52

@sagarwanojwar01
Copy link

Please refer the above images.

@sagarwanojwar01
Copy link

Hi ,
SlidingUpPanelLayout needs to have 2 children . My requirement is that the PeekingOut height of 2nd child should be transparent. This works fine if the first child is an Imageview or Text view, but if the first child is LinearLayout with its own children then we get a white background for the PeekingOut height as can be seen from the images i have uploaded before.

Can anyone help me to find a solution to make that white background transparent.
Thanks in advance!

@sagarwanojwar01
Copy link

Thanks ShakeJ.

Actually the margin for 1st child was causing the problem.
Resolved it by removing the margin.

@tokudu
Copy link
Contributor

tokudu commented Apr 7, 2014

Transparency support has been added in da90ba7. You should simply set overlay to true, and then change the background color of the sliding child to whatever you desire.

@tokudu tokudu closed this as completed Apr 7, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants