Setting placeholder programmatically in hierarchy does not respect scaleType
See original GitHub issueI’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:
- Created 8 years ago
- Comments:10 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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)
However, what is about this bug? I think if we don’t specify placeholderScaleType explicitly, Drawee should scaleType defined in xml, shouldn’t it?