2016-11-05 67 views
3

我正在使用畢加索圖書館加載圖像和它的工作正常,但使用此庫後圖像不適合佈局。如果我直接將圖像設置爲圖像視圖,然後圖像將適合於layout.Is有任何選項傳遞方法畢加索以適應圖像佈局Android使用畢加索圖書館適合全幅圖像

Picasso.with(getContext()) 
        .load(R.drawable.dddd). 
        .into(lavdateimageView); 

即使我試圖通過下面的方法,但沒有用

fit()croptinside()

XML文件

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#ffffff" 
    android:orientation="vertical"> 


    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:scrollbars="none" 
     android:background="#ffffff" 
     > 


     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
      android:background="#ffffff" 
      > 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="260dp" 
       android:layout_marginBottom="3dp" 
       android:id="@+id/lavdate_image" 
       android:orientation="vertical" 

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

        android:id="@+id/lavdateimageView" /> 
      </LinearLayout> 
      <TextView 

       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:text="New Text to" 
       android:padding="3dp" 
       android:background="#ffffff" 
       android:textColor="#000000" 
       android:layout_margin="3dp" 
       android:textStyle="bold" 
       android:id="@+id/sss" /> 

     </LinearLayout> 
    </ScrollView> 



</LinearLayout> 

回答

3

是我終於明白我犯錯誤使用android:scaleType="centerCrop",現在我的形象適合佈局

<ImageView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:scaleType="centerCrop" 
     android:id="@+id/myimageviw" /> 
9

我也有同樣的問題,所以我想這是正常工作

Picasso.with(getContext()).load(IMAGE_URL) 
      .fit() 
      .centerCrop() 
      .into(imageView); 
+0

@ Fetal.thanks.but這個我已經嘗試過,但沒有用 – iCoders

+0

@iCoders嘗試它,因爲它是...是指配合和centerCrop的同時,將工作完美 –

+0

@Fetal如果我使用這個,那麼它不會顯示我的圖像。 gues我需要改變我的xml – iCoders

0

試試改變你的imageview這樣的屬性

<ImageView 
       android:id="@+id/lavdateimageView" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:adjustViewBounds="true" 
       android:scaleType="centerCrop" 
      /> 

然後

Picasso.with(getContext()).load(R.drawable.dddd) 
      .fit() 
      .centerCrop() 
      .into(lavdateimageView) 
+0

@ shuvro.Thanks我已經厭倦了android:scaleType =「centerCrop」,它的工作正常now.you可以看到我的答案 – iCoders