FadingActionBar icon indicating copy to clipboard operation
FadingActionBar copied to clipboard

Preserve LayoutParams of header layout to enable setting a specific height

Open hdodenhof opened this issue 11 years ago • 4 comments

Currently a layout_height for a header image set in the header layout resource is being ignored.

Consider the following example:

<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="250dp"
    android:scaleType="centerCrop"
    android:src="@drawable/foobar"/>

With that I would expect the header image to have an exact height of 250dp but it doesn't. It seems the actual height just depends on the drawable and probably the ScaleType.

With this change the LayoutParams of the header layout are being kept when inflating to avoid this behavior.

hdodenhof avatar Jan 26 '14 15:01 hdodenhof

That's exactly the issue i'm now facing..

I tried it with your code, does not seem to work for me ..

Still displays full image size instead of defined in layout_height

ghost avatar Jan 26 '14 17:01 ghost

Are you using headerLayout(int layoutResId) or headerView(View view) to add the header? The provided fix does only work for the former.

hdodenhof avatar Jan 27 '14 10:01 hdodenhof

So I added the header with headerView, cleaned the project, but still the size is the image size..

<ImageView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="120dp" android:scaleType="centerCrop" android:src="@drawable/compressed" />

and then

FadingActionBarHelper helper = new FadingActionBarHelper() .actionBarBackground(R.drawable.ab_solid_goodstudent) .lightActionBar(false).headerView(headerview).headerOverlayLayout(R.layout.datepager) .parallax(true) .contentLayout(R.layout.activity_timeline);

Still no change..

ghost avatar Jan 27 '14 17:01 ghost

It actually only works with headerLayout(int layoutResId), as said before. If that's how you did it in the first place, I'm not sure what's going wrong. I just verified that this works with all the included samples, which should cover most cases.

Try building the samples from my fork after adjusting each header.xml and look for differences to your implementation.

hdodenhof avatar Jan 28 '14 11:01 hdodenhof

It's now working, I really don't know why, I really did not change anything then..

Very weird, but I'm very thankful for your fix!

Dankeschöön

ghost avatar Jan 28 '14 15:01 ghost

+1, @ManuelPeinado merge this pull request please

ChrisMCMine avatar Jun 21 '14 19:06 ChrisMCMine

Could be great to add this merge, I´m now facing the same problems as they did. By the way, the merged fix works like a charm.

reixa00 avatar Sep 17 '14 15:09 reixa00