如何获得比其父级更大的视图?

时间:2013-04-12 08:59:20

标签: android view

我有一个带有显示/隐藏菜单按钮的顶栏。我想以相同的布局定义顶部栏,按钮和菜单。

我尝试使用顶部栏的高度进行布局,但菜单被裁剪并且不可见。是否可能有比其父级更大的视图。否则,这样做的标准方法是什么?

enter image description here

1 个答案:

答案 0 :(得分:11)

对于你的问题:是的,这是可能的。简单的例子:

<?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>

ImageViewWidth == LinearLayoutWidth + 100dp

希望得到它的帮助。

相关问题