2016-12-14 4 views
0

RelativeLayoutで動的な高さを垂直に積み重ねようとしています(イメージがダウンロードされて表示されるため、高さが分からない)。青い四角形がImageViewを表し、赤色がその他のRelativeLayoutを表す、次のイメージの右側の図。動的な高さのImageViewとRelativeLayoutを垂直に積み重ね

enter image description here

これまでのところ私は以下試してみた、それは私の左側の図(レイアウトが重なっ)の出力を提供します。

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:card_view="http://schemas.android.com/apk/res-auto" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    card_view:cardCornerRadius="2dp" 
    card_view:cardUseCompatPadding="true" 
    card_view:overlay="@drawable/default_selector"> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

     <!-- ImageView represented by Blue rectangle --> 
     <ImageView 
      android:id="@+id/thumb_image_view" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:adjustViewBounds="true" 
      android:scaleType="fitXY" /> 

     <!-- RelativeLayout represented by Red rectangle --> 
     <RelativeLayout 
      android:id="@+id/thumb_bottom_view" 
      android:layout_width="match_parent" 
      android:layout_height="@dimen/default_height" 
      android:layout_alignParentBottom="true" 
      android:animateLayoutChanges="true" 
      android:gravity="center_vertical"> 

      <TextView 
       android:id="@+id/thumb_text_resolution" 
       android:layout_width="wrap_content" 
       android:layout_height="match_parent" 
       android:gravity="center_vertical" 
       android:paddingLeft="@dimen/default_gap" 
       android:paddingRight="@dimen/default_gap" 
       android:textColor="@color/Thumb.Text" 
       android:textSize="14sp" /> 

      <ImageButton 
       android:id="@+id/thumb_button_heart" 
       android:layout_width="@dimen/default_press_size" 
       android:layout_height="@dimen/default_press_size" 
       android:layout_alignParentRight="true" 
       android:layout_centerVertical="true" 
       android:background="?heartBackground" 
       android:scaleType="centerInside" 
       android:src="@drawable/ic_action_heart_empty" /> 

     </RelativeLayout> 
    </RelativeLayout> 
</android.support.v7.widget.CardView> 

右側の図のように変更する必要はありますか?

答えて

0

android:layout_alignParentEnd="true" を削除し、代わりにandroid:layout_below="@+id/thumb_image_view"を追加して修正しました。

<RelativeLayout 
    android:id="@+id/thumb_bottom_view" 
    android:layout_width="match_parent" 
    android:layout_height="@dimen/default_height" 
    android:layout_below="@+id/thumb_image_view" 
    android:animateLayoutChanges="true" 
    android:gravity="center_vertical"> 
関連する問題