manuelpeinado / fadingactionbar Goto Github PK
View Code? Open in Web Editor NEWAndroid library implementing a fading effect for the action bar, similar to the one found in the Play Music app
License: Apache License 2.0
Android library implementing a fading effect for the action bar, similar to the one found in the Play Music app
License: Apache License 2.0
I'm using FaddingActionbar, with header and overlayHeader , i'm using picasso to show the header and the overlay image.
Header height is set to 250dp but ignored when image displayed.
Header:
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/img"
android:layout_width="match_parent"
android:layout_height="250dp"
android:contentDescription="@string/content_description_image"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
/>
OverlayHeader:
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" >
<ImageView
android:id="@+id/img_small"
android:layout_width="100dp"
android:layout_height="100dp"
android:contentDescription="@string/content_description_image"
android:layout_centerVertical="true" android:layout_centerHorizontal="true"/>
</FrameLayout>
and i'm using Scollview feature.
Thank you for the lib it's awesome ! And thank you for help.
I struggle with getting the OnClick event of my header view. Tried to set the image that I got in my header layout as clickable and assigned a listener - but that does not work, apparently because the layout is more complex at the end and other elements obstruct the way and are on top of my ImageView?
Could you extend your library, your FadingActionBarHelper
, to allow adding of a listener via a simple setOnHeaderClickListener(OnClickListener)
helper method?
Thanks!
Your lib is great but it can be initialized with only resource ids. And you are using setContentView of the activity. So this cannot be used with fragments. Maybe you should have another helper method in which ScrollView and HeaderView are the actual parameters not the ids.
Can i use this library with AppCompat library instead of ActionBarSherlock?
I tried to customize the header layout, but it seems that it's not possible without visual artifacts. Is it possible or we must keep the simple ImageView header ?
The intended effect is to get a small shadow above picture's bottom.
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="200dp"
android:adjustViewBounds="true">
<ImageView
android:id="@+id/image_header"
android:layout_width="match_parent"
android:layout_height="200dp"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="@drawable/stadium_four" />
<View
android:layout_width="fill_parent"
android:layout_height="7dp"
android:layout_alignParentBottom="true"
android:background="@drawable/bottom_shadow" />
</RelativeLayout>
EDIT: Indeed, the xml didn't paste correctly and here is the effect on samsung galaxy note 2 (4.2.2)
Hi
I appreciate this library a lot! Could you suggest how I could make the image scrollable to fullscreen too? The header image could be a subset of the actual image.
Thanks
I have tried to set content view (as ListView) background but unfortunately, it will make header view (LinearLayout) gone and invisible (replaced by blank, content view background color).
Anyway I can set content view background color without affecting the header view?
I just custom the header layout, with a edittext in it. But when i click the edittext, the soft keyboard can not show.
Any one knows how to fix it ? Thanks
Whenever I load the layout and then use Picasso to load the image, the layout is misplaced (http://imgur.com/CDAm11w), is there any way to load the image FIRST then add the content layout? Thanks
Hey guys,
I want to implement viewpager below the header image.
An fragment view pager which will contain list view or scollview, etc & while scrolling the list the fading will happen.
I hope someone can help me.
Thanks in advance.
Hei, Do you put this project to Maven as jar?
I have tried get it throught http://mvnrepository.com/,but it's not working.
When using a WebView with the FadingActionBar, there is a part in the end of the content of the WebView cut off, which makes it unusable.
I first thought it had something to do on my side, but I noticed the same issue occurs in the demo app, where the bottom of the Wikipedia page is cut off.
I used to use FAB with actionbarsherlock on 2.x applications, but lately it doesn't work on 2.x again, (API 8 to be specific)...
03-12 21:13:46.263: E/AndroidRuntime(331): FATAL EXCEPTION: main
03-12 21:13:46.263: E/AndroidRuntime(331): java.lang.NoSuchMethodError: android.app.Activity.getActionBar
03-12 21:13:46.263: E/AndroidRuntime(331): at com.manuelpeinado.fadingactionbar.FadingActionBarHelper.initActionBar(FadingActionBarHelper.java:30)
full log at http://pastebin.com/58SSin4V
Can someone please confirm this is not an issue with FAB
Im trying to make a header that sometimes is longer then my screen height, but for some reason the screen height of my device seems to be the maximum height the headerview can be.
Is there any workarounds for this? To enable the headerviews height to become greater than the height?
Just like in the Google Music app, it would be awesome to easily attach "floating" action buttons on top of a list, hovering over the header image but detached from it when you slide your list, so that it basically seems to be linked to the topmost list item.
See red rectangle around the button in my screenshot.
If that could also be accomplished by the FadingActionBarHelper - wow! ;-)
I have a very specific scenario which I've found that doesn't cause the action bar to fade:
Most of the code of the sample (of "SampleFragmentActivity.java" and "SampleFragment.java") remained intact.
Only changes I've made is to let the activity decide which fragment to use, using "setListNavigationCallbacks" , and made the activity extend from SherlockFragmentActivity, and the fragment extend from SherlockFragment .
The only thing that is related to this problem that I've found is here:
http://stackoverflow.com/questions/22588662/how-to-trigger-selectors-from-the-layout-view
But they don't offer a solution.
How could it be? What can be done to handle it?
EDIT: it seems to occur even without ABS, using the sample project inside "samples\stock" , and even with the compat sample.
This is very cool feature, I really want to use it in my app.
However, it seems like can not work with customized adapter.
Am I right?
Is there any method to solve it ?
Thanks
I am using your library in my project but seems that there is a bug .
I have a listview in a fragment and for the header image i load it from url . now every thing works great
but sometimes while scrolling the imageview in the header does not hide and drawn below the listview .
please fix this .
Hello
I want to use FadingActionBar with my project. I had a look at samples-stock folder but none of them seems to fit my case.
My situation is that I have an Activity that contains a Fragment. A fragment contains header layout and content layout in the same XML.
Here is my Activity and Layout files:
UserActivity.java ( https://gist.github.com/PcNy/befe5465bc7b9008e0b1 )
activity_user.xml ( https://gist.github.com/PcNy/bc726e21d8c0ad608093 )
fragment_user_n1.xml ( https://gist.github.com/PcNy/78237f2f9b8dbdc42592 )
In my Fragment's OnCreateView, this is done.
View rootView = inflater.inflate(R.layout.fragment_user_n1, container, false);
then return rootView. But in samples, it just called View view = mFadingHelper.createView(inflater);
and return view.
Really need help to make FadingActionBar work in my case.
Thank you.
Great work so far. It'd be nice to be able to set the transparency value of the action bar. I noticed in the onNewScroll method you use the ratio of 255. Maybe have a method called mFadingHelper.setTransparencyRatio(double ratio) where that ratio of 255 is then multiplied by a transparency value.
For example I want the action bar to stay at 50% but setting a drawable of #50000000 doesn't do the trick!
I'd do a pull request but this seems like an easy fix. If you want me to add it thought let me know!
Its like navigation drawer snapping. I found fever app does.
Hello i'm having a small problem with the library. i have used the example of the NavigationDrawer in my project and instead of having the switch of the fragment in the activity i have it inside to the PlaceholderFragment which extends a Fragment. when i click on a row is throw me this error message 02-13 00:25:40.668: E/AndroidRuntime(23175): at com.georgiospanayi.fragments.SingleFragment.onAttach(SingleFragment.java:45)
How i can solve it?
Here a small example of my code which is inside the PlaceholderFragment
// update the main content by replacing fragments
Fragment fragment = new SingleFragment();
Bundle args = new Bundle();
args.putString(SingleFragment.ARG_IMAGE_RES, this.list.get(position).get_Image());
fragment.setArguments(args);
FragmentManager fragmentManager = this.main_activity.getFragmentManager();
fragmentManager.beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).replace(R.id.container, fragment).commit();
Hello,
I would like to use it with HoloEverywhere library (https://github.com/Prototik/HoloEverywhere). When trying to use it, the library send me an error message saying that my activity should be an instance of SherlockActivity (and it is the HoloEverywhere activity...).
Thnks and congrats for yout great work!!
Hi,
Thanks for this EXCELLENT library. I wanted to implement 2 tabs both with scrollview. Is it possible to implement ?
On the listview sample :
1- in landscape mode, the list go over the image when I'm scrolling down (see the attchemnt)
2 - in portrait mode, When I'm at the top of the list (arriving on the screen) this is fine. But there is a light grey overlay that come from the bottom and overlays the list while I'm scrolling down. ( see the attchemnt)
Tested on Galaxy S (the first one) with Cyanogen, android version 4.1.2
Hello, i'm a small "issue" when translucent the Actionbar. From the image you cann see that there is a white overlay starting from the top and going down only actionbar.Im pointing it with a red arrow. How i can remove it?
I'm using a custom theme on my application but the activity has as theme AppTheme.TranslucentActionBar.
Thank you
Thank for this library, very appreciated! I have one problem though, I use ViewPager from support lib inside header layout but it wont intercept touch events to swap between inner fragments. Any thoughts? Thank you.
soo, I got a solution to fix the problem where the background flashes to foreground if the app get's continued.
in Rootlayout just comment out
//get last header and listViewBackground position
int headerTopPrevious = mHeaderContainer.getTop();
int listViewBackgroundTopPrevious = mListViewBackground != null ? mListViewBackground.getTop() : 0;
//relayout
super.onLayout(changed, left, top, right, bottom);
//revert header top position
int headerTopCurrent = mHeaderContainer.getTop();
if (headerTopCurrent != headerTopPrevious) {
mHeaderContainer.offsetTopAndBottom(headerTopPrevious - headerTopCurrent);
}
//revert listViewBackground top position
int listViewBackgroundTopCurrent = mListViewBackground != null ? mListViewBackground.getTop() : 0;
if (listViewBackgroundTopCurrent != listViewBackgroundTopPrevious) {
mListViewBackground.offsetTopAndBottom(listViewBackgroundTopPrevious - listViewBackgroundTopCurrent);
}
}
this.
After that it works like a charm for me :)
Sorry i did not send a pull request but I don't actually use git
Hi,
Thanks for this excellent library. I'm using this library with ListView & header image.
But I wanna change the header image dynamically which I'm unable to achieve
Here is my header.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/picture"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="@drawable/defaultart"
android:contentDescription="@string/album_title" />
</FrameLayout>
Is there any way to change the image of the imageview used in header.xml ????
It looks like you're already using Gradle. Accoding to http://gradleplease.appspot.com/ this library is available as an apklib but not aar.
Would you mind adding it?
Hi,
I notice some strange behaviour when putting the image in the header dynamically after it has been downloaded. It seems like the height of the header only get's put in right after scrolling. Before scrolling the header just has the default size. I have tried inflating and recreating views but this does not seem to work. Does anyone have any idea how to fix this?
I got a problem with a ListView in combination with the FadingActionBar.
Once every minute I recalculate the displayed data and call notifyDataSetChanged on the associated adapter.
But every time this happens, the header image gets visible and is visible THROUGH the scrolled list. Only if the list is at its top position, everything stays fine.
Do you have any idea why this happens?
Thanks!
When I import the library project in eclipse FadingActionBarHelper tells me that the class has an error in the init action bar when accessing the activity that receives the method getActionBar ().
Suppose the header has this layout:
-vertical LinearLayout
-imageView that takes the entire parent
-bottom layout with some views
I would like the background to scroll as usual (using the parallax effect), yet the bottom layout to move together with the content itself (the listView/scrollView/etc... below the header).
I've tried to negate this effect in the FadingActionBarHelperBase.java class as such:
public void setStickyView(final View v) {
mStickeyView = v;
}
private void addParallaxEffect(final int scrollPosition) {
final float damping = mUseParallax ? 0.5f : 1.0f;
final int dampedScroll = (int) (scrollPosition * damping);
int offset = mLastDampedScroll - dampedScroll;
if (mStickeyView != null) {
int stickeyOffset = -offset + mLastScrollPosition - scrollPosition;
mStickeyView.offsetTopAndBottom(stickeyOffset);
}
mHeaderContainer.offsetTopAndBottom(offset);
if (mListViewBackgroundView != null) {
offset = mLastScrollPosition - scrollPosition;
mListViewBackgroundView.offsetTopAndBottom(offset);
}
if (mFirstGlobalLayoutPerformed) {
mLastScrollPosition = scrollPosition;
mLastDampedScroll = dampedScroll;
}
}
and it works fine, but is it the best way to achieve it?
Can anyone please add this feature, or tell me how to add it correctly?
Hi,
Thanks for this excellent library. But I wanna change the image which is shown in header view.
Hi, I am using FAB in an activity which contains a LinearLayour with some views inside.
One of them is a TextView which I expand and reduce, and when I do so with some scroll done (so I am not seeing all the header image), the header image is displaced up, so if I expand and reduce some times it eventually get out of sight.
I think it's related to the size of the linearlayout, but I don't know how to solve it, I tried some things but without any results.
My expandable text view is inside a relativeLayout, and this is the code that expands and reduces:
show = (Button) findViewById(R.id.show);
show.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
show.setVisibility(View.INVISIBLE);
hide.setVisibility(View.VISIBLE);
descripcion.setMaxLines(Integer.MAX_VALUE);
}
});
hide = (Button) findViewById(R.id.hide);
hide.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
hide.setVisibility(View.INVISIBLE);
show.setVisibility(View.VISIBLE);
descripcion.setMaxLines(5);
}
});
Is there any support for a MapView as the header? It doesn't need touch functionality, just the ability to take a location command and display it as the header instead of an image.. thanks!
Find the log below:
FATAL EXCEPTION: main
Process: com.manuelpeinado.fadingactionbar.demo, PID: 4612
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.manuelpeinado.fadingactionbar.demo/com.manuelpeinado.fadingactionbar.demo.ScrollViewActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2215)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2265)
at android.app.ActivityThread.access$800(ActivityThread.java:145)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1206)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5081)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.manuelpeinado.fadingactionbar.FadingActionBarHelperBase.createScrollView(FadingActionBarHelperBase.java:242)
at com.manuelpeinado.fadingactionbar.FadingActionBarHelperBase.createView(FadingActionBarHelperBase.java:139)
at com.manuelpeinado.fadingactionbar.FadingActionBarHelperBase.createView(FadingActionBarHelperBase.java:114)
at com.manuelpeinado.fadingactionbar.demo.ScrollViewActivity.onCreate(ScrollViewActivity.java:34)
at android.app.Activity.performCreate(Activity.java:5241)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2169)
... 11 more
I see you have pom's in other projects you made on github.
Could you also mavenise this one?
ViewPager in contentLayout is can't sliding
I've noticed that when you use a listView in this library, the background of it will always be the same - the holo light style background.
instead, I offer the next changes:
FadingActionBarHelperBase.java :
add field :
private int mListViewColor = 0;
add function:
public T setListViewColor(final int listViewColor) {
this.mListViewColor = listViewColor;
return (T) this;
}
and modify the function "createListView.java" :
// Make the background as high as the screen so that it fills regardless of the amount of scroll.
mListViewBackgroundView = contentContainer.findViewById(R.id.fab__listview_background);
if (mListViewColor != 0)
mListViewBackgroundView.setBackgroundColor(mListViewColor);
final FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mListViewBackgroundView.getLayoutParams();
sample usage:
FadingActionBarHelper helper= ... ..setListViewColor(LISTVIEW_BACKGROUND_COLOR);
I have this weird issue where only one item of the data-set is shown. I am initializing the FAB Helper class, providing it with the header view and content view and then setting the content to the helper object. Everything works fine, I get the header image and a list view, but the list contains only 1 item. My data-set contained around 10 items but only 1 of them is displayed.
I have a SO question opened with others having the same problem.
SO link : http://stackoverflow.com/questions/20800402/fading-action-bar-android-shows-only-one-item-in-list
Thank for this library, very appreciated! I have one problem though, I use ViewPager from support lib inside header layout but it wont intercept touch events to swap between inner fragments. Any thoughts? Thank you.
I'm trying to add the fadingactionbar in the NavDrawerActivity which has a listview fragment with a header that has a viewpager.
What I originally did was to inflate the headerview and add it as a headerview to the listview. But after I made changes to have this library in effect, the content of the header doesn't show even though it maintains its space.
Hello Manuel.
I want to use your library at a project but I am having hard time accomplish a rather common scenario I believe.
I have a fragment where I want to present a listView and a progress bar that is visible while the content is loading. I use a RelativeLayout with a ListView and another RelativeLayout inside (for the loader).
What should be the configuration of the FadingActionBar and the layout that can accomplish this functionality, while still having the parallax effect ?
Having something like:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/windowBackground"
android:orientation="vertical"
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="15dp"
android:text="This is a long text that can be even longer sometimes and go to more than one lines. Really !"
android:textAppearance="@android:style/TextAppearance.Medium" />
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:cacheColorHint="@android:color/transparent" />
/RelativeLayout>
has as a result the list to have a height of as big as a single entry is.
Any help would be appreciated :)
I've got java.lang.NoSuchMethodError: android.app.Activity.getActionBar on Android 2.3.
I'm using ActionBarCompat. My build.gradle:
dependencies {
...
compile 'com.github.manuelpeinado.fadingactionbar:fadingactionbar-abc:3.1.2'
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.