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