sliding drawer with content below it - android

I am having a sliding drawer positioned at the bottom . and below that I have a linear layout of 50dp .
So my layout looks like this :
Where red rectangle is the sliding drawer handle
Now when I slide my finger from bottom of the screen to the sliding drawer , i.e. along the blue path
The sliding drawer doesn't open . It doesn't open because the click activity is captured by the bottom layout.
The sliding drawer opens only when I click EXACTLY within the red rectangle.
I tried making the bottom layout clickable=>false focussable=>false still no good.
Any idea on how can I make the click event of bottom layout loose its click as soon as the finger is out of the layout ? , so that the handle can capture the click

I would suggest you to create the entire linear layout (brown bottom bar) as handler for your drawer. Doing so will allow you to slide the drawer as you want in the second picture.
Or, alternatively, you can make use of FrameLayout to present LinearLayout and drawer's view as with in a single layout and set the width and height of your drawer as linear layout - covering the entire area of linear layout.
Or, at last, implement SimpleOnGestureListener on linearlayout (for upwards direction) to execute drawer's click action.

You said you tried clickable=false and focusable=false... did you also set focusableintouchmode=false? (I would set all three and see what happens).
As I painfully discovered recently, focusable-false only covers the hardware, not the touch screen. I had to add focusableintouchmode="false".. maybe that will work for you too.

Related

How to Create menu top and bottom both of them in Android?

I wanna create a menu that be seen when clicked on the center of screen like Aldiko.
I've tested PopupWindow for create menu items but I didn't any solution for trackbar.
Are there any solutions?
Using Default Menu you can create Bottom or TOP layout. So you cant used this. But you can create your own layouts. Align one layout to top & second to bottom. Initially did INVISIBLE both layouts, when you click on center then VISIBLE both layouts.
You can use split ActionBar for getting something like you want. The only repercussion of using it will be the look in different screen modes (portrait and landscape). Your action items will align themselves as per the available screen space. Let me know if you are looking for some code for doing it with ActionBar.
You can use FrameLayout and put the main app layout on back frame and menu (with transparent background) on the top frame. Initial set the visibility of the menu layout to invisible so you app main layout would only be visible. Now when you clicks on the main layout just change the visibility to visible, when user press again set the top layout again to invisible.

How to make sliding drawer to overlay other elements in Android?

I am trying to implement a sliding drawer where handler is a button/text.
The main reason behind that is to save space. What I hope to achieve is that the drawer would open content op top of the original view. But what actually happens is that the drawer uses a relative space (button+content) in my original view.
I hope picture below will explain it more carefully. So I have a speaker icon in the drawer as a handler. I would like it to take only those 20dp or so space. When I click on the speaker, then the drawer content overlays data below. When you click on the speaker again, the drawer closes. For now, if I emulate this case, the drawer opens/closes only in the region indicated by blue rectangle.
Judging by your screenshot, your sliding drawer is inside of a LinearLayout.
Therefore it cannot do what you are looking for. (As the items in the LinearLayout will be listed linearly - therefore won't overlay)
The documentation here: http://developer.android.com/reference/android/widget/SlidingDrawer.html says you should only use the Sliding drawer in a Relative or Framelayout (as these allow overlaying):
SlidingDrawer should be used as an overlay inside layouts. This means
SlidingDrawer should only be used inside of a FrameLayout or a
RelativeLayout for instance.
I would recommend the following structure:
Relative Layout
-Sliding Drawer (id: slidingDrawer, aligned to parent top)
-Linear Layout (id: contentLyout, aligned as below id:slidingDrawer)
--TextView (id: deviceTitle)
--ScrollView (id: contentScroll)
---LinearLayout (I can't see the rest of your layout)

How to shift parent layout to right without changing inner components layout?

In my application I want to have sliding menu on the left side just like facebook.
In my previous question I had raised concern regarding the same and thanks to this answer that I could found a way to slide my layout to right using this library. But, I found that, the library does not actually slides the layout, instead it just takes the screenshot and slides the image towards right as the components on the layout are not clickable. And I need those components to be clickable. So, I tried a new way of achieving this by putting the slideout menu on the left by keeping its default visibility to View.GONE and make it visible on click on left top corner "Show/hide Menu" button as shown in figure below.
Layout before:
Now when I click "Show/Hide Menu" button, the layout is something like-
Layout after:
As you can see, the layout on the right shrinks and so the button "Some other view" changes its width even if I've set the android:minWidth attribute to those two buttons on the right as well as its parent RelativeLayout.
So my question is, is there any way to shift the layout towards right without the inner components changing their width/layout? So in whatever area is available for my view, it will be filled by whatever portion of the content that can be filled in in that area.
This problem can be solved like this:
create framelayout with inside: first left menu with 3 buttons and second layout that contains other two buttons (show/hide and other view). This way, the second layout is in front of menu (since it is fill_parent).
in onClick of show/hide button perform translate animation: assuming that your menu is 200px wide, move the second layout by 200 to the right.
in onAnimationEnd, set margins to the second layout like this: secondLayoutLayoutParams.setMargins(200, 0, -200, 0);
Closing menu is similar: move the second layout to the left by 200 and set all margins to 0.
By setting margins you will avoid button shrinking.
Hope it helps
#Rajkiran - I have a root layout, that contains my left & right layouts.
My right layout has layout_height set to 'match_parent' & layout_widht is also set to 'match_parent'
Now when my left sliding panel appears on button click, I reset the width & height of my right layout programmatically to match the width & height of the root layout.
This perfectly shifts the right layout towards right without the inner components wrapping up.
To change height & width programatically I used this -
rootLayoutParams = new LayoutParams(rootLayout.getWidth(), rootLayout.getHeight());
rightLayout.setLayoutParams(rootLayoutParams);
Hope it helps you as well.

Sliding Drawer with multiple handles

I want to create sliding drawers which comes from right to left which has two handles for loading different contents. Handles position should be in between center and bottom of the screen, so that whenever I slide with any handle, application should show the corresponding content on the whole screen.
I checked earlier sliding drawer's questions and solutions, but could not help to my scenario.
By default slide drawer's handle position is centre right to the
screen. And when I place two handles, second handle is over-lapping
the other, and I can see only one handle.
Tried keeping PaddingBottom as 200dp. Now I could see both the
handles, but second slide drawer's content is shown for both the
handles.
Kept slide drawers inside linear layout, and assigned layout_weight
as 1 for both slide drawers. With this, complete screen is divided
into two equal parts. But I want to use whole screen for each handle.
Could someone help in this regard.
Thanks in advance.
The sliding drawer can be placed in a frame or relative layout according to the developer's site. And you can set the top offset for your layout inside the layout present in the drawer which is in the xml. Hope it works. Worked fine for my code.

Button below the sliding drawer is registering the click

I have a linearlayout at the bottom of the screen. its width fills the screen and that layout has a button which fills the layout.. above that layout have a sliding drawer in the middle of the screen which is half the linearlayout width.I have Programatically made sliding drawer to come to front by calling it with bringtofront() method. Problem i m facing is the button inside the linearlayout takes the click in the space between the content items. I need it to take the click only outside the sliding drawer but not inside the content of the sliding drawer,, can anyone help me out please..
Thanks in advance :)
Take a boolean which holds slider status(open/close)
if(open)
//Disable button's click
else
//Enable button's click

Categories

Resources