2

我在Android Studio中使用CardView,我想使用ImageView來顯示一些圖像,但問題是它不顯示完整圖像。我想縮放它以顯示完整圖像。完整圖像將不會在CardView中顯示

這裏是我的代碼部分:

 <android.support.v7.widget.CardView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginBottom="@dimen/card_margin" 
      android:layout_marginLeft="@dimen/card_margin" 
      android:layout_marginRight="@dimen/card_margin"> 

      <LinearLayout 
       style="@style/Widget.CardContent" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"> 

       <TextView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:text="more" 
        android:textAppearance="@style/TextAppearance.AppCompat.Title" /> 

       <a.extera.CustomTxtView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:id="@+id/txt_more" 
        android:lineSpacingExtra="7dp" 
        android:textSize="18dp" 
        android:text="more" /> 

       <ImageView 
        android:id="@+id/backdrop1" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:scaleType="centerInside" 
        android:fitsSystemWindows="true" 
        android:orientation="vertical" 
        android:layout_alignParentLeft="true" 
        android:layout_alignParentStart="true" 
       /> 

       <a.extera.CustomTxtView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:id="@+id/txt_more2" 
        android:lineSpacingExtra="7dp" 
        android:textSize="18dp" 
        android:text="more" /> 

       <ImageView 
        android:id="@+id/backdrop2" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:scaleType="centerInside" 
        android:fitsSystemWindows="true" 
        android:layout_centerVertical="true" 
        android:layout_centerHorizontal="true" 
        android:orientation="vertical" 
        app:layout_collapseMode="parallax" 
        /> 

       <a.extera.CustomTxtView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:id="@+id/txt_more3" 
        android:lineSpacingExtra="7dp" 
        android:textSize="18dp" 
        android:text="more" /> 

       <ImageView 
        android:id="@+id/backdrop3" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:scaleType="centerInside" 
        android:fitsSystemWindows="true" 
        android:layout_centerVertical="true" 
        android:layout_centerHorizontal="true" 
        android:adjustViewBounds="true" 
        android:orientation="horizontal" 
        app:layout_collapseMode="parallax" /> 

       <a.extera.CustomTxtView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:id="@+id/txt_more4" 
        android:lineSpacingExtra="7dp" 
        android:textSize="18dp" 
        android:text="more" /> 


       <ImageView 
        android:id="@+id/backdrop4" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:scaleType="centerInside" 
        android:fitsSystemWindows="true" 
        android:layout_centerVertical="true" 
        android:layout_centerHorizontal="true" 
        android:orientation="vertical" 
        app:layout_collapseMode="parallax" 
        android:adjustViewBounds="false" /> 

       <a.extera.CustomTxtView 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:id="@+id/txt_more5" 
        android:lineSpacingExtra="7dp" 
        android:textSize="18dp" 
        android:text="more" /> 

       <ImageView 
        android:id="@+id/backdrop5" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:scaleType="centerInside" 
        android:layout_centerVertical="true" 
        android:layout_centerHorizontal="true" 
        android:orientation="vertical" 
        android:fitsSystemWindows="true" 
        app:layout_collapseMode="parallax" 
        android:adjustViewBounds="false" /> 

      </LinearLayout> 

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

例如這是完整的圖像:

https://s32.postimg.org/mntlijbn9/a_2.jpg

這是它表明:

https://s32.postimg.org/s6fyuyd91/image.jpg

+0

嘗試在Android的'使用'fitCenter',而不是'centerInside':scaleType'屬性? –

+0

我還使用了fitCenter,但仍然dosent顯示完整圖像 – ASHKAN

+0

您可以發佈當前行爲和所需行爲的屏幕截圖? –

回答

0

變化android:scaleType="centerInside"中的ImageView到android:scaleType="fitXY"

+0

我改變了它,但沒有發生 – ASHKAN

+0

在ImageView中更改** android:layout_width =「match_parent」** ** android:layout_width =「wrap_content」** –

+0

當移動是它顯示幾乎所有的圖像,但是當它的肖像只顯示圖像的一部分 – ASHKAN