本文整理汇总了Java中android.support.design.widget.CoordinatorLayout.LayoutParams方法的典型用法代码示例。如果您正苦于以下问题:Java CoordinatorLayout.LayoutParams方法的具体用法?Java CoordinatorLayout.LayoutParams怎么用?Java CoordinatorLayout.LayoutParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.design.widget.CoordinatorLayout
的用法示例。
在下文中一共展示了CoordinatorLayout.LayoutParams方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onDependentViewChanged
import android.support.design.widget.CoordinatorLayout; //导入方法依赖的package包/类
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) {
maybeInitProperties((ImageView) child, dependency);
final int maxScrollDistance = (int) (startToolbarPosition - getStatusBarHeight());
float expandedPercentageFactor = dependency.getY() / maxScrollDistance;
float distanceYToSubtract = ((startYPosition - finalYPosition)
* (1f - expandedPercentageFactor)) + (child.getHeight() / 2);
float distanceXToSubtract = ((startXPosition - finalXPosition)
* (1f - expandedPercentageFactor)) + (child.getWidth() / 2);
float heightToSubtract = ((startHeight - finalHeight) * (1f - expandedPercentageFactor));
child.setY(startYPosition - distanceYToSubtract);
child.setX(startXPosition - distanceXToSubtract);
CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) child.getLayoutParams();
lp.width = (int) (startHeight - heightToSubtract);
lp.height = (int) (startHeight - heightToSubtract);
child.setLayoutParams(lp);
return true;
}
示例2: onCreateDialog
import android.support.design.widget.CoordinatorLayout; //导入方法依赖的package包/类
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog mSheet = super.onCreateDialog(savedInstanceState);
View contentView = View.inflate(getContext(), R.layout.bottom_sheet_recycler, null);
mSheet.setContentView(contentView);
unbinder = ButterKnife.bind(this, mSheet);
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) ((View) contentView.getParent()).getLayoutParams();
CoordinatorLayout.Behavior behavior = params.getBehavior();
if (behavior != null && behavior instanceof BottomSheetBehavior) {
bottomSheetBehavior = (BottomSheetBehavior) behavior;
bottomSheetBehavior.setPeekHeight(ScreenUtil.dip2px(getContext(), PEEK_HEIGHT));
bottomSheetBehavior.setBottomSheetCallback(mBottomSheetBehaviorCallback);
}
mToolbar.setNavigationIcon(R.drawable.ic_close_white_24dp);
mToolbar.setNavigationOnClickListener(this);
onPostCreate(this);
return mSheet;
}
示例3: onCreateDialog
import android.support.design.widget.CoordinatorLayout; //导入方法依赖的package包/类
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog mSheet = super.onCreateDialog(savedInstanceState);
View contentView = View.inflate(getContext(), R.layout.bottom_sheet_share, null);
mSheet.setContentView(contentView);
unbinder = ButterKnife.bind(this, mSheet);
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) ((View) contentView.getParent()).getLayoutParams();
CoordinatorLayout.Behavior behavior = params.getBehavior();
if (behavior != null && behavior instanceof BottomSheetBehavior) {
bottomSheetBehavior = (BottomSheetBehavior) behavior;
bottomSheetBehavior.setBottomSheetCallback(mBottomSheetBehaviorCallback);
}
onPostCreate(this);
return mSheet;
}
示例4: onNestedScroll
import android.support.design.widget.CoordinatorLayout; //导入方法依赖的package包/类
@Override
public void onNestedScroll(@NonNull CoordinatorLayout coordinatorLayout,
@NonNull FloatingActionButton child,
@NonNull View target,
int dxConsumed,
int dyConsumed,
int dxUnconsumed,
int dyUnconsumed) {
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
//child -> Floating Action Button
if (dyConsumed > 0) {
Log.d("Scrolling", "Up");
CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) child.getLayoutParams();
int fab_bottomMargin = layoutParams.bottomMargin;
child.animate().translationY(child.getHeight() + fab_bottomMargin).setInterpolator(new LinearInterpolator()).start();
} else if (dyConsumed < 0) {
Log.d("Scrolling", "down");
child.animate().translationY(0).setInterpolator(new LinearInterpolator()).start();
}
}
示例5: onCreateDialog
import android.support.design.widget.CoordinatorLayout; //导入方法依赖的package包/类
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog mSheet = super.onCreateDialog(savedInstanceState);
View contentView = View.inflate(getContext(), R.layout.bottom_sheet_emoticons, null);
mSheet.setContentView(contentView);
unbinder = ButterKnife.bind(this, mSheet);
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) ((View) contentView.getParent()).getLayoutParams();
CoordinatorLayout.Behavior behavior = params.getBehavior();
if (behavior != null && behavior instanceof BottomSheetBehavior) {
bottomSheetBehavior = (BottomSheetBehavior) behavior;
bottomSheetBehavior.setBottomSheetCallback(mBottomSheetBehaviorCallback);
}
onPostCreate(this);
return mSheet;
}
示例6: layoutChild
import android.support.design.widget.CoordinatorLayout; //导入方法依赖的package包/类
@Override
protected void layoutChild(final CoordinatorLayout parent, final View child, final int layoutDirection) {
final List<View> dependencies = parent.getDependencies(child);
final View header = findFirstDependency(dependencies);
if (header != null) {
final CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) child.getLayoutParams();
final Rect available = mTempRect1;
available.set(parent.getPaddingLeft() + lp.leftMargin, header.getBottom() + lp.topMargin,
parent.getWidth() - parent.getPaddingRight() - lp.rightMargin,
parent.getHeight() + header.getBottom() - parent.getPaddingBottom() - lp.bottomMargin);
final Rect out = mTempRect2;
GravityCompat.apply(resolveGravity(lp.gravity), child.getMeasuredWidth(), child.getMeasuredHeight(), available, out, layoutDirection);
final int overlap = getOverlapPixelsForOffset(header);
child.layout(out.left, out.top - overlap, out.right, out.bottom - overlap);
mVerticalLayoutGap = out.top - header.getBottom();
} else {
// If we don't have a dependency, let super handle it
super.layoutChild(parent, child, layoutDirection);
mVerticalLayoutGap = 0;
}
}
示例7: onNestedScroll
import android.support.design.widget.CoordinatorLayout; //导入方法依赖的package包/类
@Override
public void onNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
//child -> Floating Action Button
if (dyConsumed > 0) {
CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) child.getLayoutParams();
int fab_bottomMargin = layoutParams.bottomMargin;
child.animate().translationY(child.getHeight() + fab_bottomMargin).setInterpolator(new LinearInterpolator()).start();
} else if (dyConsumed < 0) {
child.animate().translationY(0).setInterpolator(new LinearInterpolator()).start();
}
}
示例8: from
import android.support.design.widget.CoordinatorLayout; //导入方法依赖的package包/类
public static <V extends View> BottomNavigationBehavior<V> from(@NonNull V view) {
ViewGroup.LayoutParams params = view.getLayoutParams();
if (!(params instanceof CoordinatorLayout.LayoutParams)) {
throw new IllegalArgumentException("The view is not a child of CoordinatorLayout");
}
CoordinatorLayout.Behavior behavior = ((CoordinatorLayout.LayoutParams) params)
.getBehavior();
if (!(behavior instanceof BottomNavigationBehavior)) {
throw new IllegalArgumentException(
"The view is not associated with BottomNavigationBehavior");
}
return (BottomNavigationBehavior<V>) behavior;
}
示例9: form
import android.support.design.widget.CoordinatorLayout; //导入方法依赖的package包/类
public static TranslateUpDownBehavior form(View view) {
ViewGroup.LayoutParams params = view.getLayoutParams();
if (params == null || !(params instanceof CoordinatorLayout.LayoutParams)) {
throw new IllegalArgumentException("parent must be CoordinatorLayout");
}
CoordinatorLayout.Behavior behavior = ((CoordinatorLayout.LayoutParams) params).getBehavior();
if (!(behavior instanceof TranslateUpDownBehavior)) {
throw new IllegalArgumentException("the behavior must be TranslateUpDownBehavior");
}
return (TranslateUpDownBehavior) behavior;
}
示例10: move
import android.support.design.widget.CoordinatorLayout; //导入方法依赖的package包/类
private void move(float y){
dependency.setTranslationY(y);
mFrameLayout.setTranslationY(y);
ll_search.setTranslationY(y);
mRecyclerView.setTranslationY(y);
iv_img.setTranslationY(y);
//mRecyclerView高度
CoordinatorLayout.LayoutParams layoutParams= ((CoordinatorLayout.LayoutParams) mRecyclerView.getLayoutParams());
layoutParams.height= (int) (((CoordinatorLayout) mRecyclerView.getParent()).getHeight()-mRecyclerView.getY());
mRecyclerView.setLayoutParams(layoutParams);
}
示例11: CoordinatorLayoutView
import android.support.design.widget.CoordinatorLayout; //导入方法依赖的package包/类
public CoordinatorLayoutView(Context context) {
super(context);
int width = ViewGroup.LayoutParams.MATCH_PARENT;
int height = ViewGroup.LayoutParams.MATCH_PARENT;
CoordinatorLayout.LayoutParams params = new CoordinatorLayout.LayoutParams(width, height);
params.setBehavior(new AppBarLayout.ScrollingViewBehavior());
this.setLayoutParams(params);
this.setFitsSystemWindows(false);
}
示例12: onCreateDialog
import android.support.design.widget.CoordinatorLayout; //导入方法依赖的package包/类
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog mSheet = super.onCreateDialog(savedInstanceState);
View contentView = View.inflate(getContext(), R.layout.bottom_sheet_recycler, null);
mSheet.setContentView(contentView);
unbinder = ButterKnife.bind(this, mSheet);
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) ((View) contentView.getParent()).getLayoutParams();
CoordinatorLayout.Behavior behavior = params.getBehavior();
if (behavior != null && behavior instanceof BottomSheetBehavior) {
bottomSheetBehavior = (BottomSheetBehavior) behavior;
bottomSheetBehavior.setPeekHeight(ScreenUtil.dip2px(getContext(), PEEK_HEIGHT));
bottomSheetBehavior.setBottomSheetCallback(mBottomSheetBehaviorCallback);
}
mToolbar.setNavigationIcon(R.drawable.ic_close_white_24dp);
mToolbar.setNavigationOnClickListener(this);
mToolbar.inflateMenu(R.menu.menu_generic_detail);
mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
Toast.makeText(getContext(), "Showing your current favour state", Toast.LENGTH_SHORT).show();
return true;
}
});
mFavourite = mToolbar.getMenu().findItem(R.id.action_favor_state);
onPostCreate(this);
return mSheet;
}
示例13: initView
import android.support.design.widget.CoordinatorLayout; //导入方法依赖的package包/类
private void initView() {
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(mContext, R.color.color_Actionbar)));
}
mCoordinatorLayout = findViewById(R.id.coordinator);
RecyclerView recyclerView = findViewById(R.id.recycle_view);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
mAdapter = new TeacherAdapter(this, new ArrayList<Teacher>());
@SuppressWarnings("unchecked") SwingBottomInAnimationAdapter animatorAdapter = new SwingBottomInAnimationAdapter(mAdapter, recyclerView);
recyclerView.setAdapter(animatorAdapter);
ItemTouchHelper.Callback callback = new ItemTouchHelperCallBackNoMove(mAdapter);
ItemTouchHelper touchHelper = new ItemTouchHelper(callback);
touchHelper.attachToRecyclerView(recyclerView);
mView_FABMenu = findViewById(R.id.fab_menu_1);
FloatingActionButton addTeacher = findViewById(R.id.fab_action_1);
addTeacher.setVisibility(View.VISIBLE);
addTeacher.setLabelText(mContext.getResources().getString(R.string.add_teacher));
addTeacher.setOnClickListener(this);
CoordinatorLayout.LayoutParams params =
(CoordinatorLayout.LayoutParams) mView_FABMenu.getLayoutParams();
params.setBehavior(new FloatingActionMenuBehavior());
mView_FABMenu.requestLayout();
}
示例14: from
import android.support.design.widget.CoordinatorLayout; //导入方法依赖的package包/类
/**
* A utility function to get the {@link BottomSheetBehaviorGoogleMapsLike} associated with the {@code view}.
*
* @param view The {@link View} with {@link BottomSheetBehaviorGoogleMapsLike}.
* @return The {@link BottomSheetBehaviorGoogleMapsLike} associated with the {@code view}.
*/
@SuppressWarnings("unchecked")
public static <V extends View> BottomSheetBehaviorGoogleMapsLike<V> from(V view) {
ViewGroup.LayoutParams params = view.getLayoutParams();
if (!(params instanceof CoordinatorLayout.LayoutParams)) {
throw new IllegalArgumentException("The view is not a child of CoordinatorLayout");
}
CoordinatorLayout.Behavior behavior = ((CoordinatorLayout.LayoutParams) params)
.getBehavior();
if (!(behavior instanceof BottomSheetBehaviorGoogleMapsLike)) {
throw new IllegalArgumentException(
"The view is not associated with BottomSheetBehaviorGoogleMapsLike");
}
return (BottomSheetBehaviorGoogleMapsLike<V>) behavior;
}
示例15: gravityCoordinatorLayout
import android.support.design.widget.CoordinatorLayout; //导入方法依赖的package包/类
/**
* 设置Snackbar显示的位置,当Snackbar和CoordinatorLayout组合使用的时候
*
* @param gravity
*/
public SnackbarUtils gravityCoordinatorLayout(int gravity) {
if (getSnackbar() != null) {
CoordinatorLayout.LayoutParams params = new CoordinatorLayout.LayoutParams(getSnackbar().getView().getLayoutParams().width, getSnackbar().getView().getLayoutParams().height);
params.gravity = gravity;
getSnackbar().getView().setLayoutParams(params);
}
return this;
}