2013-04-12 36 views
4

我有一個帶有顯示/隱藏菜單按鈕的頂欄。我想在同一個佈局中定義頂部欄,按鈕和菜單。如何獲得比其父項更大的視圖?

我嘗試了頂部欄高度的佈局,但菜單被裁剪並且不可見。有可能有一個比它的父母更大的視圖。否則,做這件事的標準方法是什麼?

enter image description here

+0

使用scrollview .. –

+0

爲什麼你想要比父視圖更大的視圖?只要讓父母足夠大,並在其中包含內容視圖即可。 – njzk2

+0

@ njzk2:在頂部欄下方我有一個片段根據按下的菜單選項而改變,並且此片段可以具有某些手勢檢測的視圖。如果包含頂部欄和菜單的視圖與整個屏幕相匹配,它後面的「內容」視圖的手勢檢測是否仍然有效? – jul

回答

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

希望它的幫助。

+0

菜單的高度不固定,應該下降到屏幕的底部。 – jul

相關問題