How to make object overlay another object in Android layout? - android

What I am trying to do is to have a menu appear over listView. Just like in okCupid app :
when you click menu below the picture :
https://ssl.gstatic.com/android/market/com.okcupid.okcupid/ss-480-3-11
it extends itself over the background view :
https://g1.gstatic.com/android/market/com.okcupid.okcupid/ss-480-4-11
I have a feeling that this particular app is done in Sencha or JQuery mobile or similar technology but is it possible to get same effect in native app?
thanks

Most layout classes 'help you' by avoiding widgets to overlaps, but with the RelativeLayout you have more flexibility to create overlapping views.
To be sure the overlay view is on top, you can call ViewGroup.bringChildViewToFront() on the relative layout.
In your example the top view also has a partially transparent background.

Try using FrameLayout and add appropriate transperency for the view

I can look around for some example code later but the basic idea would be to have a MenuView class that draws your menu and animates in and out by setting the content of the menu visible or not.
Then just have all your content be on top of that MenuView by using the relativelayout align_parentBottom and set the content to above the menuview.

Related

Sliding up view in android. without including that view in every layout

I need to show a view sliding up for all my pages(fragments). Just like navigation drawer working. I don't want to include layout in every view and animate. Please suggest a solution
Create a common base class that your fragments extend from. What is the purpose of the sliding view? Does is just animate a scroll within a fixed space? Does it move above it up when it animates in? Does it overlay over the view as it slides up? Need more clarification.
You can use something like AndroidSlidingUpLibrary.
I'd avoid using it for scrolling views, it is nice though.

How do I make a section of an activity always-on-top?

Had a question about making part of a View Always-On-Top. Please see the Groupon picture below. The black window at the bottom where it says "From $29" & "Buy!" is always on top of the activity page. Meaning the rest of the page is scrollable above that black window at the bottom. Please note I only want this activity to have an Always-On-Top
How do I make a portion of the activity Always On Top? And what kind of layout did you think they used for Groupon? I was just going to make a RelativeLayout and layout_alignParentBottom="true".
You could probably get away with having a vertical linear layout with two children. The first one a scrollable area and the bottom a view with whatever it is you want to be 'on top'. Since there's no transparency there's no visual difference between having the black view as always-on-top and having one view on top of the other (in the y-axis, not z-axis). Plus, if you do it this way you can reach and see the bottom of the scrollable view's content.
To the best of my knowledge, the best way to do this is by implementing a BaseActivity with this View, and have all your activities extend this activity instead of the standard Activity.

ANDROID, what layout elements should I use?

I need to make an android layout like this one.
tile background all over the screen.
top menu which, overlays the background ( note the shadow ).
some sort of a table with text options, maybe pictures, which can be scrolled up and down.
bottom menu, which appears by sliding up after a menu button is hit.
What kind of layout elements do you think I should use for that?
Thanks!
I think you should first learn about the Android Layout and XML layout design, then you can easily prepare this layout as well.
Relative Layout will be the better layout as compare to other layouts like Linear Layout and Table Layout.
To display middle part that is showing textual description may contains ListView (ListView because as you have mentioned Text Options should scroll up and down), but it depends on your requirement.
The RelativeLayout is the most flexible, and I think you can make all this with a minimal hierarchy view depth.
My approach would be to use a RelativeLayout. The Top Menu bar could be a custom class which extends a LinearLayout and this can be used in the RelativeLayout (in fact in any screen you have to provide UI consistency). Similarly, the bottom menu would be a custom control containing the appropriate animations. The rest of the screen would be contained in a ScrollView, possibly containing a TableLayout. I have something very similar using a MapView in the main screen and it works fine.

Creating autohide custom view in android

I am working on creating a custom view in android. I want to create an autohide custom view control.
This control will be holding other UI elements mostly buttons or icons. It has a small button which is mandatory, clicking which will slide the control in or out thus changing its visibility.
one should be able to add other buttons or icons to this control
The control can be placed only at the borders, which needs to be specified while creating the view.
I don't know how to start with it
Should I be extending the View class or ViewGroup class.
have a look at this
and then you have to add a dynamic layout to this drawer
I used a RelativeLayout and added a Button to the View.
When I call expandView() or collapseView(), I call mybutton.setVisibility() and let RelativeLayout know it has changed with this.requestLayout().

android custom view how to draw button on top of the view

I am creating a android app using LunarLander as a example.
Now I need to create a few buttons which are drawn over the view.
I do not want them as a seperate layout above or below the view but in the custom view.
Is this possible or am I going to have to programmatically show the button images then detect the touch. The buttons I create using new never show on the app. I assume this is because I have overwritten the onDraw and the buttons are never drawn even though I call
super.onDraw(canvas);
I think you could use FrameLayout to show two layers - first would be your surface from lunar, and second is the layout with buttons etc. You could define everything in layout.xml file. Probably that is enough.
Regards!
If your view extends Linear/Relative/TableLayout, you can use view.bringChildToFront(child).
Use AbsoluteLayout & then in your ui thread set button.bringTioFront() & you are done!
watch this post Problem when using more elements in the ListView

Categories

Resources