question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Setting placeholder programmatically in hierarchy does not respect scaleType

See original GitHub issue

I’m using SimpleDraweeView as Toolbar background, for this i have set a fixed height in AppBarLayout and match_parent height for SimpleDraweeView, the image set programmatically for placeholder is getting stretched in height, even if i set programmatically the scale type to centerCrop. This is my layout res:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">
    <android.support.design.widget.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="270dp"
        android:fitsSystemWindows="true">

        <android.support.design.widget.CollapsingToolbarLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <com.facebook.drawee.view.SimpleDraweeView
                android:id="@+id/drawee_image"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:placeholderImageScaleType="centerCrop"
                app:layout_collapseMode="parallax" />
            <include layout="@layout/toolbar"/>

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

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

    <include layout="@layout/content" />
</android.support.design.widget.CoordinatorLayout>

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
bogdantmm92commented, Jun 2, 2016

This is indeed a bug. Setting a placeholder image programmatically, ignores the “placeholderScaleType” set in xml. I wanted to use fitCenter, and I had to go with this method: target.getHierarchy().setPlaceholderImage(context.getResources().getDrawable(ressourceId), ScalingUtils.ScaleType.FIT_CENTER)

0reactions
IlyaGulyacommented, Apr 24, 2017

However, what is about this bug? I think if we don’t specify placeholderScaleType explicitly, Drawee should scaleType defined in xml, shouldn’t it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Don't Use The Placeholder Attribute - Smashing Magazine
A Solution # To recap, the placeholder attribute: Can't be automatically translated; Is oftentimes used in place of a label, locking out ...
Read more >
ScaleTypes - Fresco
ScaleTypes of actual, placeholder, retry, and failure images can all be set in XML, using attributes like fresco:actualImageScaleType . You can also set...
Read more >
How can I set Picasso placeholder scaleType? - Stack Overflow
I've problem with placeholder images in Picasso. I use scaleType fitXY on one of my imageViews, but I don't really wanna scale my...
Read more >
Use placeholders to replace information depending on context
Dynamically replace a placeholder with information depending on context in Assets for Jira Service Management.
Read more >
Auto Layout Guide: Working with Constraints in Interface Builder
It does not have any effect on the view at runtime. For more information, see Setting the Placeholder Intrinsic Size for a Custom...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found