当前位置: 首页>>代码示例>>Java>>正文


Java CoordinatorLayout.LayoutParams方法代码示例

本文整理汇总了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;
}
 
开发者ID:FarshidABZ,项目名称:CoordinatorBehavior,代码行数:25,代码来源:ImageBehavior.java

示例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;
}
 
开发者ID:wax911,项目名称:anitrend-app,代码行数:25,代码来源:BottomSheetUsers.java

示例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;
}
 
开发者ID:wax911,项目名称:anitrend-app,代码行数:17,代码来源:BottomSheetShare.java

示例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();
    }
}
 
开发者ID:h4h13,项目名称:RetroMusicPlayer,代码行数:22,代码来源:ScrollAwareFABBehavior.java

示例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;
}
 
开发者ID:wax911,项目名称:anitrend-app,代码行数:21,代码来源:BottomSheetEmoticon.java

示例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;
    }
}
 
开发者ID:zuoni1018,项目名称:CoordinatorLayoutExample-master,代码行数:26,代码来源:HeaderScrollingViewBehavior.java

示例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();
    }
}
 
开发者ID:goutham106,项目名称:GmArchMvvm,代码行数:14,代码来源:FAB_Float_on_Scroll.java

示例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;
}
 
开发者ID:homeii,项目名称:GxIconAndroid,代码行数:14,代码来源:BottomNavigationBehavior.java

示例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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:TranslateUpDownBehavior.java

示例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);
}
 
开发者ID:zhengjingle,项目名称:WuBaDemo,代码行数:13,代码来源:MyBehavior.java

示例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);
}
 
开发者ID:cesardeazevedo,项目名称:react-native-collapsing-toolbar,代码行数:12,代码来源:CoordinatorLayoutView.java

示例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;
}
 
开发者ID:wax911,项目名称:anitrend-app,代码行数:36,代码来源:BottomSheetLikes.java

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

    }
 
开发者ID:nhocga1995s,项目名称:MyCalendar,代码行数:32,代码来源:TeacherListActivity.java

示例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;
}
 
开发者ID:aliumujib,项目名称:Nibo,代码行数:21,代码来源:BottomSheetBehaviorGoogleMapsLike.java

示例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;
}
 
开发者ID:lanyuanxiaoyao,项目名称:PicKing,代码行数:14,代码来源:SnackbarUtils.java


注:本文中的android.support.design.widget.CoordinatorLayout.LayoutParams方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。