Android Open Source - FadingActionBar Root Layout






From Project

Back to project page FadingActionBar.

License

The source code is released under:

Apache License

If you think the Android project FadingActionBar listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.manuelpeinado.fadingactionbar.view;
/*  w w  w. j  a  v  a  2  s.  c o m*/
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;

import com.manuelpeinado.fadingactionbar.R;

public class RootLayout extends FrameLayout {

    private View mHeaderContainer;
    private View mListViewBackground;
    private boolean mInitialized = false;

    public RootLayout (Context context) {
        super(context);
    }

    public RootLayout (Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public RootLayout (Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    protected void onLayout (boolean changed, int left, int top, int right, int bottom) {
        //at first find headerViewContainer and listViewBackground
        if (mHeaderContainer == null)
            mHeaderContainer = findViewById(R.id.fab__header_container);
        if (mListViewBackground == null)
            mListViewBackground = findViewById(R.id.fab__listview_background);

        //if there's no headerViewContainer then fallback to standard FrameLayout
        if (mHeaderContainer == null) {
            super.onLayout(changed, left, top, right, bottom);
            return;
        }

        if (!mInitialized) {
            super.onLayout(changed, left, top, right, bottom);
            //if mListViewBackground not exists or mListViewBackground exists
            //and its top is at headercontainer height then view is initialized
            if (mListViewBackground == null || mListViewBackground.getTop() == mHeaderContainer.getHeight())
                mInitialized = true;
            return;
        }

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

}




Java Source Code List

com.manuelpeinado.fadingactionbar.FadingActionBarHelperBase.java
com.manuelpeinado.fadingactionbar.FadingActionBarHelper.java
com.manuelpeinado.fadingactionbar.Utils.java
com.manuelpeinado.fadingactionbar.demo.ActivityInfo.java
com.manuelpeinado.fadingactionbar.demo.HeaderOverlayActivity.java
com.manuelpeinado.fadingactionbar.demo.HomeActivity.java
com.manuelpeinado.fadingactionbar.demo.LightActionBarActivity.java
com.manuelpeinado.fadingactionbar.demo.LightBackgroundActivity.java
com.manuelpeinado.fadingactionbar.demo.ListViewActivity.java
com.manuelpeinado.fadingactionbar.demo.NavigationDrawerActivity.java
com.manuelpeinado.fadingactionbar.demo.NoParallaxActivity.java
com.manuelpeinado.fadingactionbar.demo.SampleFragmentActivity.java
com.manuelpeinado.fadingactionbar.demo.SampleFragment.java
com.manuelpeinado.fadingactionbar.demo.ScrollViewActivity.java
com.manuelpeinado.fadingactionbar.demo.ShortContentActivity.java
com.manuelpeinado.fadingactionbar.demo.WebViewActivity.java
com.manuelpeinado.fadingactionbar.extras.actionbarcompat.FadingActionBarHelper.java
com.manuelpeinado.fadingactionbar.extras.actionbarsherlock.FadingActionBarHelper.java
com.manuelpeinado.fadingactionbar.samples.actionbarcompat.ActivityInfo.java
com.manuelpeinado.fadingactionbar.samples.actionbarcompat.HeaderOverlayActivity.java
com.manuelpeinado.fadingactionbar.samples.actionbarcompat.HomeActivity.java
com.manuelpeinado.fadingactionbar.samples.actionbarcompat.LightActionBarActivity.java
com.manuelpeinado.fadingactionbar.samples.actionbarcompat.LightBackgroundActivity.java
com.manuelpeinado.fadingactionbar.samples.actionbarcompat.ListViewActivity.java
com.manuelpeinado.fadingactionbar.samples.actionbarcompat.NoParallaxActivity.java
com.manuelpeinado.fadingactionbar.samples.actionbarcompat.SampleFragmentActivity.java
com.manuelpeinado.fadingactionbar.samples.actionbarcompat.SampleFragment.java
com.manuelpeinado.fadingactionbar.samples.actionbarcompat.ScrollViewActivity.java
com.manuelpeinado.fadingactionbar.samples.actionbarcompat.WebViewActivity.java
com.manuelpeinado.fadingactionbar.samples.actionbarsherlock.ActivityInfo.java
com.manuelpeinado.fadingactionbar.samples.actionbarsherlock.HeaderOverlayActivity.java
com.manuelpeinado.fadingactionbar.samples.actionbarsherlock.HomeActivity.java
com.manuelpeinado.fadingactionbar.samples.actionbarsherlock.LightActionBarActivity.java
com.manuelpeinado.fadingactionbar.samples.actionbarsherlock.LightBackgroundActivity.java
com.manuelpeinado.fadingactionbar.samples.actionbarsherlock.ListViewActivity.java
com.manuelpeinado.fadingactionbar.samples.actionbarsherlock.NoParallaxActivity.java
com.manuelpeinado.fadingactionbar.samples.actionbarsherlock.SampleFragmentActivity.java
com.manuelpeinado.fadingactionbar.samples.actionbarsherlock.SampleFragment.java
com.manuelpeinado.fadingactionbar.samples.actionbarsherlock.ScrollViewActivity.java
com.manuelpeinado.fadingactionbar.samples.actionbarsherlock.WebViewActivity.java
com.manuelpeinado.fadingactionbar.view.ObservableScrollView.java
com.manuelpeinado.fadingactionbar.view.ObservableScrollable.java
com.manuelpeinado.fadingactionbar.view.ObservableWebViewWithHeader.java
com.manuelpeinado.fadingactionbar.view.OnScrollChangedCallback.java
com.manuelpeinado.fadingactionbar.view.RootLayout.java