4

I have a top bar with a show/hide menu button. I would like to define the top bar, the button and the menu in the same layout.

I tried a layout with the height of the top bar, but the menu is clipped and is not visible. Is that possible to have a view larger than its parent. Otherwise, what's the standard way to do that?

enter image description here

jul
  • 36,404
  • 64
  • 191
  • 318
  • why do you want to have the view bigger than the parent ? just make the parent big enough, and include the content view in it. – njzk2 Apr 12 '13 at 09:09
  • @njzk2: below the top bar I have a fragment that changes according to the menu option pressed, and this fragment can have views with some gesture detection. If the view containing the top bar and the menu matches the whole screen, will the gesture detection of the 'content' view behind it still work? – jul Apr 12 '13 at 10:10

1 Answers1

11

For your question: Yes It's possible. Simple example:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="match_parent"
          android:orientation="vertical"
          android:layout_height="match_parent"
          >

<ImageView
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="#f0f"
      android:layout_marginLeft="-50dp"
      android:layout_marginRight="-50dp"
      />
 </LinearLayout>

And ImageViewWidth == LinearLayoutWidth + 100dp.

Hope its help.

jimpanzer
  • 3,470
  • 4
  • 44
  • 84
  • The height of the menu is not fixed, it should go down to the bottom of the screen. – jul Apr 12 '13 at 15:04