2011-01-12 25 views
1

私は非常によくRelativeLayoutを理解していなかった、このXML(それがリストビューの項目を表す)で、なぜ私は理解していなかった。相対レイアウト

<?xml version="1.0" encoding="UTF-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@drawable/sfumatura_riga" 
    > 

     <ImageView 
     android:id="@+id/featured_new_image" 
     android:layout_alignParentLeft="true"   
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/no_foto" 

     /> 

     <LinearLayout 
     android:layout_toRightOf="@id/featured_new_image" 
     android:orientation="vertical" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="5dp" 
     > 

     <TextView 
      style="@style/featured_new_title" 
      android:id="@+id/featured_city" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="5dp" 
      android:layout_marginTop="10dp" 


     /> 

     <TextView 
      style="@style/featured_name_country" 
      android:id="@+id/featured_country" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
     /> 




    </LinearLayout> 

    <TextView 
      style="@style/featured_date" 
      android:id="@+id/featured_date" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="10dp" 
      android:layout_marginRight="5dp" 
      android:layout_alignParentRight="true" 
     /> 



</RelativeLayout>       

私はこの結果を満たし、なぜあまりにも余裕で行の底? alt text

+0

相対レイアウトのlayout_heightをwrap_contentに変更しようとしたら、それは機能しますか? – xandy

+0

このxmlに何か間違いはありません。 –

+0

私はそのxandyを試しましたが、うまくいきません! – pedr0

答えて

2

私は主に二つのことになります。私は背景がちょうど勾配であると思いandroid:layout_height="fill_parent" to android:layout_height="wrap content"

  • を変更する、相対的なレイアウトで

    1. 。しかし、画像であれば、大きすぎて行全体が縦に伸びている可能性があります。すべてのATL
  • +0

    この状況を解決できますか? – pedr0

    +0

    あなたはnr 2を意味しますか?その場合は、画像をカットするか、グラデーションを使用します:)。すでにグラデーションであれば、それはあまり役に立たないでしょう。 –

    0

    おかげで私はそれがのLinearLayoutでRelativeLaoyoutを置き換える解決、私は解決策を共有し、私は同じ問題を抱えている誰かを助けるために願っています!

    <ImageView 
        android:id="@+id/featured_new_image" 
        android:layout_width="120dp" 
        android:layout_height="fill_parent" 
        android:src="@drawable/no_foto" 
    
        /> 
    
    <LinearLayout 
        android:orientation="vertical" 
        android:layout_weight="1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="5dp" 
        > 
    
        <TextView 
         style="@style/featured_new_title" 
         android:id="@+id/featured_city" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_marginBottom="5dp" 
         android:layout_marginTop="10dp" 
    
    
        /> 
    
        <TextView 
         style="@style/featured_name_country" 
         android:id="@+id/featured_country" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
        /> 
    
    
    
    
    </LinearLayout> 
    
    <TextView 
         style="@style/featured_date" 
         android:id="@+id/featured_date" 
         android:layout_marginTop="10dp" 
         android:layout_marginRight="5dp" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_gravity="right" 
        /> 
    

    関連する問題