Fresco: No image is displayed if set width and height wrap_content

Created on 23 Apr 2015  路  4Comments  路  Source: facebook/fresco

Example:

    private void drawSmile() {
       SimpleDraweeView image = (SimpleDraweeView) findViewById(R.id.image);
        Uri uri = Uri.parse(file);
        DraweeController controller = Fresco.newDraweeControllerBuilder()
                .setUri(uri)
                .build();
        image.setController(controller);
    }
<com.facebook.drawee.view.SimpleDraweeView
  android:id="@+id/image"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"/>

And incorrect width if set size in code:

LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(200, 100);
image.setLayoutParams(layoutParams);

Most helpful comment

i want actual image size as it is. so what is the alternative way for wrap_content...thank you

All 4 comments

wrap_content in both dimensions is not supported.

In the example you gave, you should just set the XML width and height to the values you want.

i want actual image size as it is. so what is the alternative way for wrap_content...thank you

Hello I am new for Fresco Library implementation. so please guide me where i wrong in code.

in my view of phone image height not coming properly its always coming in single line. below is complete XML file where i added com.facebook.drawee.view.SimpleDraweeView

xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:fresco="http://schemas.android.com/tools"
android:id="@+id/scrollview_linear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:orientation="vertical">

layout="@layout/remint_it_layout_include"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<RelativeLayout
    android:id="@+id/inside_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">


    <ImageView
        android:id="@+id/thumbnailVideo"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignBottom="@id/videoView"
        android:layout_alignEnd="@id/videoView"
        android:layout_alignLeft="@id/videoView"
        android:layout_alignRight="@id/videoView"
        android:layout_alignStart="@id/videoView"
        android:layout_alignTop="@id/videoView"
        android:layout_centerInParent="true"
        android:scaleType="fitXY"
        android:visibility="gone"
        android:background="#FFF"/>


    <!--<com.mintshow.utils.ScaleImageView
                    android:id="@+id/image_mint"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_alignBottom="@id/videoView"
                    android:layout_alignEnd="@id/videoView"
                    android:layout_alignLeft="@id/videoView"
                    android:layout_alignRight="@id/videoView"
                    android:layout_alignStart="@id/videoView"
                    android:layout_alignTop="@id/videoView"
                    android:layout_centerInParent="true"
                    android:layout_marginBottom="25dp"
                    android:scaleType="fitXY"
                    android:src="@drawable/loading_image"
                    android:visibility="gone" />-->

    <com.facebook.drawee.view.SimpleDraweeView
        android:id="@+id/image_mint"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:adjustViewBounds="true"
        android:layout_alignBottom="@id/videoView"
        android:layout_alignEnd="@id/videoView"
        android:layout_alignLeft="@id/videoView"
        android:layout_alignRight="@id/videoView"
        android:layout_alignStart="@id/videoView"
        android:layout_alignTop="@id/videoView"
        android:layout_centerInParent="true"
        android:layout_marginBottom="25dp"
        android:scaleType="fitXY"
        fresco:progressBarImage="@drawable/progress"
        fresco:progressBarImageScaleType="centerInside"
        fresco:progressBarAutoRotateInterval="1000"
        android:visibility="gone" />



    <im.ene.lab.toro.widget.ToroVideoView
        android:id="@+id/videoView"
        android:layout_width="match_parent"
        android:layout_height="350dp"
        android:layout_centerInParent="true"
        android:layout_gravity="center"
        app:videoScaleMode="fitWidth"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:visibility="gone"/>


    <ImageView
        android:id="@+id/imageviewYoutuneLogo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:src="@drawable/youtube_logo"
        android:visibility="gone"
        />

    <ImageView
        android:id="@+id/imagePlayPauseCenter"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:padding="10dp"
        android:src="@drawable/new_video_play_icon"
        android:visibility="gone" />

    <LinearLayout
        android:id="@+id/layoutSeekbar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/videoView"
        android:background="@color/default_line_indicator_unselected_color"
        android:gravity="center"
        android:orientation="horizontal"
        android:visibility="gone">

        <TextView
            android:id="@+id/textStartTime"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0"
            android:text="00.00"
            android:textColor="#FFFFFF" />

        <SeekBar
            android:id="@+id/seekbarVideoTime"
            style="@android:style/Widget.Holo.SeekBar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:layout_weight="1"
            android:paddingLeft="0dp"
            android:paddingRight="0dp"
            android:thumb="@drawable/thumb_drawable"
            android:thumbOffset="0dp" />

        <TextView
            android:id="@+id/textEndTime"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="0"
            android:text="00.00"
            android:textColor="#FFFFFF" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <ImageView
            android:id="@+id/imagePlayPause"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="10dp"
            android:src="@drawable/playback_pause"
            android:visibility="gone" />

        <ImageView
            android:id="@+id/imageMuteUnmute"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="8dp"
            android:src="@drawable/unmute_audio"
            android:visibility="gone" />
    </LinearLayout>


    <ImageView
        android:id="@+id/nomination_badge"
        android:layout_width="40dp"
        android:layout_height="40dp"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:src="@drawable/achievement_badge"
        android:visibility="gone" />
</RelativeLayout>

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/inside_layout">

    <com.mintshow.utils.emoji_lib.EmojiExplorerView
        android:id="@+id/mint_text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="9dp"
        android:background="#FFFFFF"
        android:gravity="center"
        android:padding="3dp"
        android:text="30 days of Water is the best hsdfhsdf ghfg jafjhgj hsdgghdghsf hfhhfh ggfgthing 30 days of Water is the best thing "
        android:textColor="#4A4A4A"
        android:textColorLink="#F35E1B"
        android:textSize="17sp" />

    <TextView
        android:id="@+id/edited_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/mint_text"
        android:layout_marginRight="7dp"
        android:text="Edited"
        android:textSize="15sp"
        android:visibility="gone" />
</RelativeLayout>

layout="@layout/remint_headerview_show_mint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" />
layout="@layout/location_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
layout="@layout/relative_icons_include_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

android:layout_width="fill_parent"
android:layout_height="1dp"
android:layout_marginTop="3dp"
android:background="#EFEFEF" />

layout="@layout/compliments_root_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

android:id="@+id/bottom_line_divider"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginBottom="0dp"
android:layout_marginTop="5dp"
android:background="@drawable/thin_line" />

See your comment in #753

Was this page helpful?
0 / 5 - 0 ratings

Related issues

liubaoyua picture liubaoyua  路  3Comments

zewenwang picture zewenwang  路  4Comments

ykostova picture ykostova  路  3Comments

qiiyue picture qiiyue  路  4Comments

rhettor picture rhettor  路  3Comments