當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。