Search in sources :

Example 31 with CoordinatorLayout

use of android.support.design.widget.CoordinatorLayout in project ListenerMusicPlayer by hefuyicoder.

the class RotationFabBehavior method offsetIfNeeded.

/**
     * Pre-Lollipop we use padding so that the shadow has enough space to be drawn. This method
     * offsets our layout position so that we're positioned correctly if we're on one of
     * our parent's edges.
     */
private void offsetIfNeeded(CoordinatorLayout parent, FloatingActionButton fab) {
    Rect padding = new Rect(0, 0, 0, 0);
    try {
        Field mShadowPadding = FloatingActionButton.class.getDeclaredField("mShadowPadding");
        mShadowPadding.setAccessible(true);
        padding = (Rect) mShadowPadding.get(fab);
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    if (padding != null && padding.centerX() > 0 && padding.centerY() > 0) {
        final CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
        int offsetTB = 0, offsetLR = 0;
        if (fab.getRight() >= parent.getWidth() - lp.rightMargin) {
            // If we're on the right edge, shift it the right
            offsetLR = padding.right;
        } else if (fab.getLeft() <= lp.leftMargin) {
            // If we're on the left edge, shift it the left
            offsetLR = -padding.left;
        }
        if (fab.getBottom() >= parent.getHeight() - lp.bottomMargin) {
            // If we're on the bottom edge, shift it down
            offsetTB = padding.bottom;
        } else if (fab.getTop() <= lp.topMargin) {
            // If we're on the top edge, shift it up
            offsetTB = -padding.top;
        }
        if (offsetTB != 0) {
            ViewCompat.offsetTopAndBottom(fab, offsetTB);
        }
        if (offsetLR != 0) {
            ViewCompat.offsetLeftAndRight(fab, offsetLR);
        }
    }
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) Field(java.lang.reflect.Field) Rect(android.graphics.Rect)

Example 32 with CoordinatorLayout

use of android.support.design.widget.CoordinatorLayout in project instructure-android by instructure.

the class CanvasWebView method onAttachedToWindow.

@Override
protected void onAttachedToWindow() {
    super.onAttachedToWindow();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        if (getParent() instanceof CoordinatorLayout) {
            mChildHelper = new NestedScrollingChildHelper(this);
            setNestedScrollingEnabled(true);
        }
    }
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) NestedScrollingChildHelper(android.support.v4.view.NestedScrollingChildHelper)

Example 33 with CoordinatorLayout

use of android.support.design.widget.CoordinatorLayout in project SmoothRefreshLayout by dkzwm.

the class QuickConfigAppBarUtil method onDetached.

@Override
public void onDetached(SmoothRefreshLayout layout) {
    layout.setOnFooterEdgeDetectCallBack(null);
    layout.setOnHeaderEdgeDetectCallBack(null);
    CoordinatorLayout coordinatorLayout = findCoordinatorLayout(layout);
    if (coordinatorLayout == null)
        return;
    AppBarLayout appBarLayout = findAppBarLayout(coordinatorLayout);
    if (appBarLayout == null)
        return;
    appBarLayout.removeOnOffsetChangedListener(this);
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) AppBarLayout(android.support.design.widget.AppBarLayout)

Example 34 with CoordinatorLayout

use of android.support.design.widget.CoordinatorLayout in project Thrift-box by Sash0k.

the class ExpensesFragment method onCreateView.

// ============================================================================
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle state) {
    View expandableListView = super.onCreateView(inflater, container, state);
    CoordinatorLayout view = (CoordinatorLayout) inflater.inflate(R.layout.fragment_expenses, container, false);
    // Удаляю заглушку и добавляю ExpandableListFragment
    ListView lv = (ListView) view.findViewById(android.R.id.list);
    ViewGroup parent = (ViewGroup) lv.getParent();
    int lvIndex = parent.indexOfChild(lv);
    parent.removeViewAt(lvIndex);
    parent.addView(expandableListView, lvIndex, expandableListView.getLayoutParams());
    // Привязываю fab к новому listView
    lv = (ListView) view.findViewById(android.R.id.list);
    FloatingActionButton fab = (FloatingActionButton) view.findViewById(R.id.expenses_fab);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent i = new Intent();
            i.setClass(getContext(), StatisticsActivity.class);
            startActivity(i);
        }
    });
    fab.attachToListView(lv);
    return view;
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) StatisticsActivity(ru.sash0k.thriftbox.StatisticsActivity) ListView(android.widget.ListView) ExpandableListView(android.widget.ExpandableListView) ViewGroup(android.view.ViewGroup) FloatingActionButton(com.melnykov.fab.FloatingActionButton) Intent(android.content.Intent) View(android.view.View) ListView(android.widget.ListView) ExpandableListView(android.widget.ExpandableListView)

Example 35 with CoordinatorLayout

use of android.support.design.widget.CoordinatorLayout in project weiui by kuaifan.

the class StatusBarUtil method setColorForSwipeBack.

/**
 * 为滑动返回界面设置状态栏颜色
 *
 * @param activity       需要设置的activity
 * @param color          状态栏颜色值
 * @param statusBarAlpha 状态栏透明度
 */
public static void setColorForSwipeBack(Activity activity, @ColorInt int color, @IntRange(from = 0, to = 255) int statusBarAlpha) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        ViewGroup contentView = ((ViewGroup) activity.findViewById(android.R.id.content));
        View rootView = contentView.getChildAt(0);
        int statusBarHeight = getStatusBarHeight(activity);
        if (rootView != null && rootView instanceof CoordinatorLayout) {
            final CoordinatorLayout coordinatorLayout = (CoordinatorLayout) rootView;
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
                coordinatorLayout.setFitsSystemWindows(false);
                contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
                boolean isNeedRequestLayout = contentView.getPaddingTop() < statusBarHeight;
                if (isNeedRequestLayout) {
                    contentView.setPadding(0, statusBarHeight, 0, 0);
                    coordinatorLayout.post(new Runnable() {

                        @Override
                        public void run() {
                            coordinatorLayout.requestLayout();
                        }
                    });
                }
            } else {
                coordinatorLayout.setStatusBarBackgroundColor(calculateStatusColor(color, statusBarAlpha));
            }
        } else {
            contentView.setPadding(0, statusBarHeight, 0, 0);
            contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
        }
        setTransparentForWindow(activity);
    }
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) ViewGroup(android.view.ViewGroup) View(android.view.View)

Aggregations

CoordinatorLayout (android.support.design.widget.CoordinatorLayout)57 View (android.view.View)37 AppBarLayout (android.support.design.widget.AppBarLayout)17 TextView (android.widget.TextView)15 ViewGroup (android.view.ViewGroup)13 RecyclerView (android.support.v7.widget.RecyclerView)12 Intent (android.content.Intent)9 Toolbar (android.support.v7.widget.Toolbar)8 Snackbar (android.support.design.widget.Snackbar)7 ViewParent (android.view.ViewParent)7 ImageView (android.widget.ImageView)7 NavigationView (android.support.design.widget.NavigationView)5 ViewPager (android.support.v4.view.ViewPager)5 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)5 SearchView (android.support.v7.widget.SearchView)5 LayoutInflater (android.view.LayoutInflater)5 FrameLayout (android.widget.FrameLayout)5 TabLayout (android.support.design.widget.TabLayout)4 PagerAdapter (android.support.v4.view.PagerAdapter)4 NestedScrollView (android.support.v4.widget.NestedScrollView)4