2017-02-22 6 views
0

私はrecyclerviewを持っていて、その中にはNetworkImageViewとテキストビューがあります。イメージサイズに応じてNetworkImageViewとTextViewの間のスペース

NetworkImageViewの画像によっては、画像が小さい場合は空白が追加されますが、画像が大きい場合は画像とtextviewの間に大きな空白が追加されます。だから、最初の写真で、それは画像と名前/出版社の間には大きなスペースがあり

space no space

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <android.support.v7.widget.CardView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

     <LinearLayout 
      android:padding="@dimen/activity_horizontal_margin" 
      android:orientation="vertical" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" > 

      <com.android.volley.toolbox.NetworkImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:padding="0dp" 
       android:id="@+id/imageViewHero" /> 

      <TableLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"> 

       <TableRow> 
        <TextView 
         android:text="Name" 
         android:paddingRight="10dp" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         /> 

        <TextView 
         android:id="@+id/textViewName" 
         android:textStyle="bold" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         /> 

       </TableRow> 

       <TableRow> 
        <TextView 
         android:text="Publisher" 
         android:paddingRight="10dp" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         /> 

        <TextView 
         android:id="@+id/textViewPublisher" 
         android:textStyle="bold" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         /> 

       </TableRow> 

      </TableLayout> 
     </LinearLayout> 
    </android.support.v7.widget.CardView> 

</RelativeLayout> 

どのように私はこのスペースを削除するか(その代わり、このランダムなものの)私自身を追加することができますか?

答えて

1

レイアウトをデバッグすると、実際にはNetworkImageViewが空白を占めていることがわかりますが、画像の比率はスペース全体を埋めることができません。 NetworkImageViewに

android:adjustViewBounds="true" 

を追加してみてください。

+0

あなたは素晴らしいです、ありがとう! –

関連する問題