2016-05-26 8 views
0

Während des Ladens erscheint eine dünne Linie und das Bild ist nicht sichtbar, während Fresco in einem RecyclerView auf Android Jellybean Geräten, aber das gleiche funktioniert auf KitKat + Geräten.Fresco Bild nicht sichtbar in Recyler View on Android Jellybean Geräte

Samsung - 4.1.1 - API 16 bis 768 X 1280

Loading Image Using Fresco

SamsungGalaxyNote2 - 4.3 - API 18 bis 720 X 1280

enter image description here

HINWEIS: Wird in mehreren Geräten und das Szenario ist das gleiche Das ist die Art, wie wir es

  if (newsModelStoreList.get(position-1).getImageUrl() != null) { 
      String imageUrl = newsModelStoreList.get(position-1).getImageUrl(); 
      String extension=".jpg"; 
      try { 
       extension = imageUrl.substring(imageUrl.lastIndexOf(".")); 
      } 
      catch (Exception e) 
      { 

      } 

      Log.d("extension: ",extension); 
      if(extension.equals(".gif")) { 
       Log.d("Detected Gif: ", "Starting gif controller"); 
       DraweeController controller = Fresco.newDraweeControllerBuilder() 
         .setUri(Uri.parse(imageUrl)) 
         .setAutoPlayAnimations(true) 
       .build(); 
       myHolder.newsImage.setController(controller); 

      } 
      else 
      { 
       myHolder.newsImage.setImageURI(Uri.parse(imageUrl)); 
      } 

     } 

ICH BIN 100% sicher in der Bibliothek verwenden

getestet, die URL verfügbar und arbeitet an 4.4+ DEVICES

Dies ist der news_layout.xml der aufgeblasen wird

<?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="wrap_content" 
    android:background="@color/feed_bg" 
    android:orientation="vertical" > 

    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:background="@drawable/bg_parent_rounded_corner" 
     android:layout_marginTop="@dimen/feed_item_margin" 
     android:orientation="vertical" 
     android:paddingBottom="@dimen/feed_item_padding_top_bottom" 
     android:paddingTop="@dimen/feed_item_padding_top_bottom" > 

     <LinearLayout 
      android:layout_width="fill_parent" 
      android:gravity="right" 
      android:layout_height="wrap_content"> 

      <TextView 
       android:id="@+id/timestamp" 
       android:gravity="right" 
       android:paddingRight="10dp" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:text="posted 5 min ago" 
       android:textColor="@color/timestamp" 
       android:textSize="@dimen/feed_item_timestamp" /> 

     </LinearLayout> 

     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/newsTitle" 
      android:textSize="22dp" 
      android:clickable="false" 
      android:textStyle="bold" 
      android:paddingLeft="@dimen/feed_item_status_pad_left_right" 
      android:paddingRight="@dimen/feed_item_status_pad_left_right" 
      android:textColor="@color/black" 
      android:textColorLink="@color/com_facebook_blue" 
      android:layout_marginBottom="5dp" 
      android:paddingBottom="5dp" 
      /> 

     <TextView 
      android:id="@+id/newsInformation" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:paddingBottom="5dp" 

      android:textColor="@color/black" 
      android:textColorLink="@color/com_facebook_blue" 
      android:paddingLeft="@dimen/feed_item_status_pad_left_right" 
      android:paddingRight="@dimen/feed_item_status_pad_left_right" 
      android:paddingTop="@dimen/feed_item_status_pad_top" > 


      </TextView> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/viewMore" /> 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_gravity="right" 
      android:layout_height="wrap_content"> 

     </LinearLayout> 

SimpleDraweeView hier verwendet wird ...

 <com.facebook.drawee.view.SimpleDraweeView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:scaleType="fitXY" 
      android:visibility="visible" 
      android:adjustViewBounds="true" 
      android:id="@+id/newsImage"/> 

Der Rest des xml nur als Referenz für alle Fälle wäre es

 <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="@dimen/pad_5dp"> 

      <TextView 
       android:id="@+id/awesomeness" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textColor="@color/timestamp" 
       android:text="Awesomeness: " 
       android:textSize="@dimen/feed_item_timestamp" /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/awesomenessCountNumber" 
       android:text="0" 
       android:textColor="@color/timestamp" 
       android:textSize="@dimen/feed_item_timestamp"/> 

     </LinearLayout> 

     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:paddingTop="@dimen/pad_5dp" 
      android:layout_marginLeft="@dimen/pad_5dp" 
      android:layout_marginRight="@dimen/pad_5dp"> 

      <Button 
       android:layout_width="30dp" 
       android:layout_height="30dp" 
       android:id="@+id/awesomeButton" 
       android:layout_marginRight="8dp" 
       android:background="@drawable/awesome_button_2"/> 

      <Button 
       android:layout_width="30dp" 
       android:layout_height="30dp" 
       android:id="@+id/facebookSharePost" 
       android:layout_marginRight="8dp" 
       android:background="@drawable/facebook_icon" 
       /> 

      <Button 
       android:layout_width="30dp" 
       android:layout_height="30dp" 
       android:id="@+id/whatsApp" 
       android:background="@drawable/whats_app_icon"/> 

      <View 
       android:layout_width="0dp" 
       android:layout_height="0dp" 
       android:layout_weight="1" 
       /> 

      <TextView 
       android:layout_marginRight="8dp" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Report"/> 

      <Button 
       android:layout_marginRight="6dp" 
       android:layout_width="30dp" 
       android:layout_height="30dp" 
       android:id="@+id/report" 
       android:background="@drawable/report_empty" /> 


     </LinearLayout> 

    </LinearLayout> 

</LinearLayout> 
+0

Können wir ein Code-Snippet sehen? – tyronen

+0

@Tyronen haben den Code Snipper Sir hinzugefügt –

Antwort

1

Guesses helfen was Sie falsch machen:

  • Sie verwenden wrap_content. Fresko dies nicht unterstützt, wenn Sie auch ein fresco:viewAspectRatio. liefern Siehe guide to Drawees und die longer explanation über wrap_content.
  • Sie verwenden android:scaleType. Dies hat keine Auswirkungen auf SimpleDraweeViews. Sie müssen fresco:actualImageScaleType verwenden. Stellen Sie außerdem sicher, dass fitXY wirklich das ist, was Sie wollen; Dadurch bleibt das Seitenverhältnis nicht erhalten. Siehe die Dokumentation unter scale types.
+0

1. Sir Was sollte die Breite des Bildes für den Newsfeed wo Bildlängen vorsichtig sein ??? (IMP *) 2. Es funktionierte, wenn ich eine feste Größe gebe. Warum funktioniert es in Android 4.4 + Geräten und nicht auf den anderen ???? –

+0

Die Verwendung von Fokus-Zuschneiden mit Seitenverhältnis löst mein Problem zu einem gewissen Grad. Aber immer noch wird der obere Teil des Bildes geschnitten. Was ist zu tun ?? Image Link: http://postimg.org/image/f18vz4g97/ –

+0

Wenn Sie nie möchten, dass das Bild abgeschnitten wird, verwenden Sie nicht focusCrop.Verwenden Sie fitCenter. – tyronen