FadingActionBar
FadingActionBar copied to clipboard
Preserve LayoutParams of header layout to enable setting a specific height
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.
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
Are you using headerLayout(int layoutResId)
or headerView(View view)
to add the header? The provided fix does only work for the former.
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..
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.
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
+1, @ManuelPeinado merge this pull request please
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.