2017-02-18 49 views
0

另一種看法,我想做出會低於另一種觀點認爲一個視圖,覆蓋太視圖下方,並覆蓋在Android的

我作了如下

<RelativeLayout android:layout_height="wrap_content" android:layout_width="wrap_content"> 


     <include layout="@layout/toolbar" android:id="@+id/tool" 
      /> 


     <include layout="@layout/content_main" 
      android:layout_width="match_parent" 
       android:layout_height="match_parent" 
      android:layout_below="@+id/tool" 
      android:layout_marginBottom="30dp" 
     /> 



     </RelativeLayout> 

,但它沒有工作,任何解決方案?

+0

你想實現什麼?爲什麼你需要從另一個'View'中查看? – JonZarate

+0

我不希望視圖隱藏其他,但我只想覆蓋它的一小部分,設計需要這個。 – iosamammohamed

+0

向我們展示設計 – JonZarate

回答

1

首先,你需要顛倒視圖的順序,toolbar應該隱藏content_main所以它應該在它後面添加。

其次,你可以使用切緣陰性,對於這一點,你告訴content_main將低於toolbar,然後把負上邊距就可以了,所以它的動作有點高,下面toolbar

例子:

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#ff0000" > 
    <TextView 
     android:text="first line, will be partially covered. fdjkfsjdf kldsjfkdsljfklds " 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@id/toolbar" 
     android:layout_marginTop="-20dp" 
     android:textSize="36sp" 
     android:fontFamily="sans-serif-light" 
     android:background="#00ff00"/> 
    <TextView 
     android:id="@+id/toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="100dp" 
     android:background="#0000ff" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:textSize="36sp" 
     android:text="TOOLBAR" /> 
</RelativeLayout> 

而且結果:

Result screenshot

+0

謝謝,那就是我想要的 – iosamammohamed

0

嘗試使用FrameLayout而不是RelativeLayout。

+0

我不明白這怎麼能幫到所有 – JonZarate