0

Hi i am not sure why this is not working also not sure if this is possible but here is what i am trying to do. I have a SimpleDraweeView which is contained inside a collapsingtoolbarlayout and i am trying to load an image into it.

 <android.support.design.widget.AppBarLayout
    android:id="@+id/app_bar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fitsSystemWindows="true">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/toolbar_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        app:contentScrim="?attr/colorPrimary"
        app:titleEnabled="false"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <com.facebook.drawee.view.SimpleDraweeView
            android:id="@+id/cover_image"
            android:layout_width="match_parent"
            app:layout_collapseMode="parallax"
            android:layout_height="300dp"
            fresco:placeholderImageScaleType="centerCrop"
            android:fitsSystemWindows="true"/>
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="300dp"
            android:background="#55000000"/>
        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            app:layout_scrollFlags="scroll"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_collapseMode="pin"
            app:popupTheme="@style/AppTheme.PopupOverlay"/>

    </android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>

and i am trying to set the image in my onCreate method like this.

    //gallery is my object which contains coverImage field
    Uri coverImageUri = Uri.parse(gallery.getCoverImage());
    SimpleDraweeView coverImageView = (SimpleDraweeView)findViewById(R.id.gallery_cover_image);
    Toast.makeText(this,gallery.getCoverImage(),Toast.LENGTH_SHORT).show();
    coverImageView.setImageURI(coverImageUri);

I am able to see the url in the toast but the image doesn't seem to appear. Any pointers are appreciated.Thanks.

harshitpthk
  • 4,058
  • 2
  • 24
  • 32
  • Have you gone through the steps in http://frescolib.org/docs/troubleshooting.html#_ ? If so, please post the log output here. – tyronen Feb 12 '16 at 18:37
  • It is possible that with CollapsingToolbarLayout, the onAttach/onDetach events don't get properly called. – plamenko Feb 12 '16 at 19:12
  • can you show us what you get, and also can you add a place holder image to see if it will appear? – M090009 Feb 14 '16 at 14:48

1 Answers1

0

I tried out your code and its all working fine. Your xml is ok and your java code is sound, so i guess that your problem is a simple one. I think you forgot to add the internet permission because thats the only case that didn't display the image for me, just add <uses-permission android:name="android.permission.INTERNET"/> in your manifest.xml and you'll be set.

Also I saw that you have a placeHolderScaleType and not a placeholder, so it would be a good practice to add on if you're loading images online.

And thanks for the shadowed View that you have, it actually gave me a hint to something that i wanted to do and was thinking of ways to do it.

M090009
  • 1,129
  • 11
  • 20