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


Java CoordinatorLayout.addView方法代码示例

本文整理汇总了Java中android.support.design.widget.CoordinatorLayout.addView方法的典型用法代码示例。如果您正苦于以下问题:Java CoordinatorLayout.addView方法的具体用法?Java CoordinatorLayout.addView怎么用?Java CoordinatorLayout.addView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.design.widget.CoordinatorLayout的用法示例。


在下文中一共展示了CoordinatorLayout.addView方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setAppbarEvent

import android.support.design.widget.CoordinatorLayout; //导入方法依赖的package包/类
private void setAppbarEvent() {
    AppBarLayout appBar = (AppBarLayout) getParent();

    if (appBar.getParent().getClass().equals(CoordinatorLayout.class)) {
        CoordinatorLayout rootLayout = (CoordinatorLayout) appBar.getParent();

        View tabs = getChildAt(0);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            tabs.setElevation(getResources().getDimensionPixelOffset(R.dimen.tabs_elevation));
        }

        removeView(tabs);
        rootLayout.addView(tabs);

        getLayoutParams().height = getResources().getDimensionPixelOffset(R.dimen.fancy_tab_layout_height);
        requestLayout();
        isFloating = true;
    }

    appBar.addOnOffsetChangedListener(onOffsetChangedListener);
}
 
开发者ID:ypicoleal,项目名称:FancyTab,代码行数:22,代码来源:FancyTabLayout.java

示例2: initContentView

import android.support.design.widget.CoordinatorLayout; //导入方法依赖的package包/类
/**
 * 最外面套一层 {@link CoordinatorLayout} 是为了 解锁 {@link android.support.design.widget.Snackbar} 更多姿势,例如 滑动删除
 * <p>
 * {@link StatusLayout} : 多种状态下的rootView
 * <p>
 * 这里取巧了一下,因为 {@link org.jsoup.Jsoup} 抓取的数据都可以用一个 {@link  android.support.v7.widget.RecyclerView} 来显示
 * <p>
 * {@link StatusLayout} SuccessView 并没有隐藏或者显示,
 * 因为{@link FrameLayout} 填充 View 的时候是依次重叠的,这个时候只要最先填充 SuccessView
 * 只要去控制 errorView 或者 EmptyView 隐藏或者显示就行了,会自行覆盖掉 SuccessView,真正的项目中不应该这样做,因为要处理的布局远远比这个复杂
 *
 * @return activity 根布局
 */
private View initContentView() {
    CoordinatorLayout coordinatorLayout = new CoordinatorLayout(this);
    coordinatorLayout.setId(R.id.activityRootView);
    mStatusView = new StatusLayout(this);
    mStatusView.setSuccessView(getLayoutId(), new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    mStatusView.setEmptyView(R.layout.layout_empty_view);
    mStatusView.setErrorView(R.layout.layout_network_error);
    mStatusView.getEmptyView().setOnClickListener(v -> clickNetWork());
    mStatusView.getErrorView().setOnClickListener(v -> clickNetWork());
    setStatusViewStatus(StatusLayout.SUCCESS);
    coordinatorLayout.addView(mStatusView, new CoordinatorLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    return coordinatorLayout;
}
 
开发者ID:7449,项目名称:JsoupSample,代码行数:27,代码来源:BaseActivity.java

示例3: delegation

import android.support.design.widget.CoordinatorLayout; //导入方法依赖的package包/类
public static KeyboardInputDelegation delegation(Context context, CoordinatorLayout mCoorLayout, View mScrollerView) {
    KeyboardInputDelegation delegator = new KeyboardInputDelegation(context);
    View view = LayoutInflater.from(context).inflate(R.layout.view_input_wrap, mCoorLayout, false);
    delegator.setWrapperView(view);
    delegator.setCoorLayout(mCoorLayout);
    delegator.setScrollerView(mScrollerView);
    mCoorLayout.addView(view);
    return delegator;
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:10,代码来源:KeyboardInputDelegation.java

示例4: onAttachedToWindow

import android.support.design.widget.CoordinatorLayout; //导入方法依赖的package包/类
@Override
protected void onAttachedToWindow() {
    super.onAttachedToWindow();

    LayoutParams layoutParams =
            new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    int coordinatorLayoutOffset = getResources().getDimensionPixelSize(R.dimen.coordinator_layout_offset);
    if (fabGravity == BOTTOM_END || fabGravity == TOP_END) {
        layoutParams.setMargins(0, 0, coordinatorLayoutOffset, 0);
    } else {
        layoutParams.setMargins(coordinatorLayoutOffset, 0, 0, 0);
    }
    menuItemsLayout.setLayoutParams(layoutParams);

    // Needed in order to intercept key events
    setFocusableInTouchMode(true);

    if (useTouchGuard) {
        ViewParent parent = getParent();

        touchGuard = new View(getContext());
        touchGuard.setOnClickListener(this);
        touchGuard.setWillNotDraw(true);
        touchGuard.setVisibility(GONE);

        if (touchGuardDrawable != null) {
            touchGuard.setBackground(touchGuardDrawable);
        }

        if (parent instanceof FrameLayout) {
            FrameLayout frameLayout = (FrameLayout) parent;
            frameLayout.addView(touchGuard, frameLayout.indexOfChild(this));
        } else if (parent instanceof CoordinatorLayout) {
            CoordinatorLayout coordinatorLayout = (CoordinatorLayout) parent;
            coordinatorLayout.addView(touchGuard, coordinatorLayout.indexOfChild(this));
        } else if (parent instanceof RelativeLayout) {
            ((RelativeLayout) parent).addView(
                    touchGuard, ((RelativeLayout) parent).indexOfChild(this),
                    new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                            ViewGroup.LayoutParams.MATCH_PARENT));
        } else {
            Log.d(TAG, "touchGuard requires that the parent of this FabSpeedDialer be a FrameLayout or RelativeLayout");
        }
    }

    setOnClickListener(this);
}
 
开发者ID:kranthi0987,项目名称:easyfilemanager,代码行数:48,代码来源:FabSpeedDial.java

示例5: onAttachedToWindow

import android.support.design.widget.CoordinatorLayout; //导入方法依赖的package包/类
@Override
protected void onAttachedToWindow() {
    super.onAttachedToWindow();

    LayoutParams layoutParams =
            new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    int coordinatorLayoutOffset = getResources().getDimensionPixelSize(R.dimen.coordinator_layout_offset);
    if (fabGravity == BOTTOM_END || fabGravity == TOP_END) {
        layoutParams.setMargins(0, 0, coordinatorLayoutOffset, 0);
    } else {
        layoutParams.setMargins(coordinatorLayoutOffset, 0, 0, 0);
    }
    menuItemsLayout.setLayoutParams(layoutParams);

    // Set up the client's FAB
    fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setImageDrawable(fabDrawable);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        fab.setImageTintList(fabDrawableTint);
    }
    if (fabBackgroundTint != null) {
        fab.setBackgroundTintList(fabBackgroundTint);
    }

    fab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (isAnimating) return;

            if (isMenuOpen()) {
                closeMenu();
            } else {
                openMenu();
            }
        }
    });

    // Needed in order to intercept key events
    setFocusableInTouchMode(true);

    if (useTouchGuard) {
        ViewParent parent = getParent();

        touchGuard = new View(getContext());
        touchGuard.setOnClickListener(this);
        touchGuard.setWillNotDraw(true);
        touchGuard.setVisibility(GONE);

        if (touchGuardDrawable != null) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                touchGuard.setBackground(touchGuardDrawable);
            } else {
                touchGuard.setBackgroundDrawable(touchGuardDrawable);
            }
        }

        if (parent instanceof FrameLayout) {
            FrameLayout frameLayout = (FrameLayout) parent;
            frameLayout.addView(touchGuard);
            bringToFront();
        } else if (parent instanceof CoordinatorLayout) {
            CoordinatorLayout coordinatorLayout = (CoordinatorLayout) parent;
            coordinatorLayout.addView(touchGuard);
            bringToFront();
        } else if (parent instanceof RelativeLayout) {
            RelativeLayout relativeLayout = (RelativeLayout) parent;
            relativeLayout.addView(touchGuard,
                    new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                            ViewGroup.LayoutParams.MATCH_PARENT));
            bringToFront();
        } else {
            Log.d(TAG, "touchGuard requires that the parent of this FabSpeedDialer be a FrameLayout or RelativeLayout");
        }
    }

    setOnClickListener(this);

    if (shouldOpenMenu)
        openMenu();
}
 
开发者ID:Alcatraz323,项目名称:MaterialOCR,代码行数:81,代码来源:FabSpeedDial.java


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