Android - Positioning layout items relative to top of sliding drawer handle - android

I would like to position an element of an activity's layout relative to the top of a sliding drawer handle in its closed state. The standard Layout above relative layout attribute obviously doesn't work given the floating nature of sliding drawer.
It seems to me that the only (non-programmatic) alternative is to bottom-align and used fixed margins or bottom padding to ensure the element sits above the closed sliding drawer handle. This approach is pretty crude and I'm hoping to avoid this because I would like the sliding drawer handle height to be dependent on its content (which is dynamic).
Any suggestions to help achieve a more fluid layout?

You can control the height of the sliding drawer if you want to and I think that is the case with this question. The sliding drawer is just taking some space of the screen and other content should be above it

Can't you use a LinearLayout (Vertical), and set its position to bottom-align

Related

how to set slider in both side android

I am trying to make sliding drawer menu like the one in the YouTube app. I navigated many questions like this amazing one here. and found a lot of libraries but all of them slide from left to right or from right to left in different one. I want to make it slide from both sides, left to right and right to left via two buttons in the top bar.
You can look at github.com/Ali-Rezaei/SlidingDrawer, which mekes it possible for you to slide from any side.
Use Yahoo Rangeseekbar
The package is
com.yahoo.mobile.client.android.util.rangeseekbar
It will let you slide both the sides and you can choose if you want to display the values on the top of the slider min and max ends.
You can use the standard DrawerLayout from the support library. As it says in the documentation, you can control the placement of the drawers with the layout_gravity attribute. From the documentation:
To use a DrawerLayout, position your primary content view as the first child with a width and height of match_parent. Add drawers as child views after the main content view and set the layout_gravity appropriately. Drawers commonly use match_parent for height with a fixed width.

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)

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.

sliding drawer with content below it

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.

Scrolling Navigation Bar Help Android

I was wondering how to create a navigation bar
like the one at the top of the screen that moves when "flicked" or scrolled.
Use a HorizontalScrollView, wrapped around a LinearLayout of Buttons or ImageButtons.

Categories

Resources