2017-11-15 16 views
0

私はRelativeLayout内にImageViewを持っています。 RelativeLayout高さは50dpに固定され、ImageViewの高さは50dpより大きい。 ImageViewがRelativeLayoutを横切るようにしたい。ImageViewがrelativelayoutを超えない理由

私は実装したい画面を添付します。

enter image description here

<RelativeLayout 
android:id="@+id/btnMenu" 
android:layout_width="match_parent" 
android:layout_height="50dp" 
android:background="#000000" 
      android:clipChildren="false" 
      android:clipToPadding="false"> 

      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerVertical="true" 
       android:background="@drawable/home_menu" 
       android:layout_alignParentLeft="true"/> 

      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerVertical="true" 
       android:background="@drawable/home_logo_bottom" 
       android:layout_alignParentRight="true"/> 

     </RelativeLayout> 
+0

あなたは「相対レイアウトを渡る」とはどういう意味ですか? – Henry

+0

私はカスタムデザインの要件を持って、私は自分が望む写真を添付し​​ました。 ありがとう –

+0

ありがとうございます。私の答えをチェックアウトする。この "横断"をしたい場合は、ImageViewを子として持つことはできません。 RelativeLayoutの外に持ってきてください。 – Henry

答えて

1

RelativeLayout親会社であるとImageViewは、その内部の子です。ルールは、子が親より大きい場合、親が表示されているものだけが切り取られるように子を切り取ることです。したがって、親の高さが50dpで、子の高さが100dpの場合、子供の50dpのコンテンツのみが表示されます。

この場合、ImageViewのコンテンツ全体を表示したい場合は、RelativeLayoutのlayout_heightwrap_contentに変更してください。イメージのようにレイアウトを実行したい場合は、ImageViewをRelativeLayoutの子として作成しないでください。

0

を使用して、2つの相対的なレイアウト

<RelativeLayout 
    android:id="@+id/parentlayout" 
    android:layout_width="match_parent" 
    android:layout_height="60dp" 
    android:background="#000000"> 

    <RelativeLayout 
    android:id="@+id/btnMenu" 
    android:layout_width="match_parent" 
    android:layout_height="50dp" 
    android:layout_alignParentBottom="true" 
    android:background="#000000"> 

     <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerVertical="true" 
      android:background="@drawable/home_menu" 
      android:layout_alignParentLeft="true"/> 


     </RelativeLayout> 

    <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerVertical="true" 
      android:background="@drawable/home_logo_bottom" 
      android:layout_alignParentRight="true"/> 

    </RelativeLayout> 
関連する問題