Giter Site home page Giter Site logo

manuelpeinado / fadingactionbar Goto Github PK

View Code? Open in Web Editor NEW
2.9K 2.9K 679.0 14.72 MB

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

Groovy 6.72% Java 93.28%

fadingactionbar's People

Contributors

antoniolg avatar manuelpeinado avatar mozarcik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fadingactionbar's Issues

Mavenise

I see you have pom's in other projects you made on github.
Could you also mavenise this one?

Header misplaced after scrolling down and turning off screen

Great library, I'm loving it, but one thing has caught my attention. When scrolling down an activity, if you happen to turn off your screen and then scroll back up, the header image gets misplaced.

Scroll down some and turn off screen..
2013-12-02-18-48-10

Scroll back up and you will see this :(
2013-12-02-18-48-43

How i can remove an overlay from actionbar?

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?
image

I'm using a custom theme on my application but the activity has as theme AppTheme.TranslucentActionBar.

Thank you

Transparency Value

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!

MapView as header

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!

NoSuchMethodError FAB with ActionBarSherlock on 2.x

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

Possibility to have a Fragment with a RelativeLayout as root and a listview along with other elements inside

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 :)

Solution for weird layout problem found!

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

setting ContentView background and HeaderView will be invisible

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?

Can headerview be longer then screen height?

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?

Strange behaviour when loading image from web

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?

Fullscreening the header image

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

Unable to change the header view image

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 ????

Header ImageView not hidden sometimes and drawn below the listview

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 .

notifyDataSetChanged() in List combined with FadingActionBar destroys view

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.

screenshot_2013-06-24-22-33-13

Do you have any idea why this happens?
Thanks!

Add tab navigation

Hi,

Thanks for this EXCELLENT library. I wanted to implement 2 tabs both with scrollview. Is it possible to implement ?

NPE on sample app.[Untouched]

  • I have just imported the lib and stock sample app in Eclipse
  • Resolved the dependencies
  • Build successfully
  • After install on my mobile observed NPE on activity launch

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

Add fragment view pager as content layout

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.

How could I implement an OnClickListener for the header image?

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!

ViewPager inside header layout

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.

WebView not showing full content

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.

error on onAttach

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();

[SOLVED] Transparent actionbar is not working on fragment

Hello everyone, i'm trying to use the fadingActionBar on my app and i used the code of the SampleFragment.java but i'm having a small issue. as you can see in the image the actionbar is not transparent. what i'm doing wrong? thank you
screenshot_2014-02-25-12-03-41

NavigationDrawer Activity with listview fragment

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.

Header background image displacement when hide/show 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);

        }
    });

5554avd_for_nexus_one_by_google

Feature request - adding action icons that float over header image

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.

image

If that could also be accomplished by the FadingActionBarHelper - wow! ;-)

ViewPager inside header layout

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.

ABS+ICS/JB+navigation list => no fading action bar when scrolling

I have a very specific scenario which I've found that doesn't cause the action bar to fade:

  1. ActionBarSherlock being used
  2. activitiy with navigation list, which allows to switch between the fragments within it.
  3. OS is Android 4.0 or 4.1.2 , but not newer (newer seems to work fine).

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.

layout_height ignored

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.

HoloEverywhere

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!!

Only 1 item in listview

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

Request: allow (almost) sticky view on the header

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?

Customize header layout

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)
device-2014-01-26-141432

2 bugs on the ListView sample

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

landscape
overlay

Request - add listView background

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);

header layout and content layout in the same fragment

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.

Using only with resource ids.

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.