2017-02-22 5 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 фактически занимает пустое пространство, но коэффициент изображения не позволяет заполнить все пространство. Попробуйте добавить

android:adjustViewBounds="true" 

в NetworkImageView.

+0

Вы удивительны, спасибо! –

Смежные вопросы