Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a view larger than its parent?

Tags:

android

view

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

like image 802
jul Avatar asked Dec 21 '22 07:12

jul


1 Answers

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.

like image 61
jimpanzer Avatar answered Jan 02 '23 10:01

jimpanzer