當前位置: 首頁>>代碼示例>>Java>>正文


Java ViewGroup.removeViewAt方法代碼示例

本文整理匯總了Java中android.view.ViewGroup.removeViewAt方法的典型用法代碼示例。如果您正苦於以下問題:Java ViewGroup.removeViewAt方法的具體用法?Java ViewGroup.removeViewAt怎麽用?Java ViewGroup.removeViewAt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.ViewGroup的用法示例。


在下文中一共展示了ViewGroup.removeViewAt方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onConfigurationChanged

import android.view.ViewGroup; //導入方法依賴的package包/類
@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    StyledAttributesHelper ta = StyledAttributesHelper.obtainStyledAttributes(this,
            new int[] { R.attr.actionBarSize });
    ViewGroup.LayoutParams params = mFakeToolbar.getLayoutParams();
    params.height = ta.getDimensionPixelSize(R.attr.actionBarSize, 0);
    mFakeToolbar.setLayoutParams(params);
    ta.recycle();
    if (mToolbar != null) {
        ViewGroup group = (ViewGroup) mToolbar.getParent();
        int i = group.indexOfChild(mToolbar);
        group.removeViewAt(i);
        Toolbar replacement = new Toolbar(group.getContext());
        replacement.setPopupTheme(mToolbar.getPopupTheme());
        AppBarLayout.LayoutParams toolbarParams = new AppBarLayout.LayoutParams(
                AppBarLayout.LayoutParams.MATCH_PARENT, params.height);
        replacement.setLayoutParams(toolbarParams);
        group.addView(replacement, i);
        setSupportActionBar(replacement);
        addActionBarDrawerToggle(replacement);
    }
}
 
開發者ID:MCMrARM,項目名稱:revolution-irc,代碼行數:24,代碼來源:MainActivity.java

示例2: detachTrackerFrameLayout

import android.view.ViewGroup; //導入方法依賴的package包/類
private void detachTrackerFrameLayout(Activity activity) {
    if (activity == null || activity instanceof TabActivity) {
        return;
    }

    try {
        ViewGroup container = (ViewGroup) activity.findViewById(android.R.id.content);

        if (container == null) {
            return;
        }

        if (container.getChildAt(0) instanceof TrackerFrameLayout) {
            container.removeViewAt(0);
        }
    } catch (Exception e) {
        TrackerLog.e(e.toString());
    }

}
 
開發者ID:alibaba,項目名稱:android_viewtracker,代碼行數:21,代碼來源:TrackerManager.java

示例3: clearPreviousSetting

import android.view.ViewGroup; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.KITKAT)
private static void clearPreviousSetting(Activity activity) {
    ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
    int count = decorView.getChildCount();
    if (count > 0 && decorView.getChildAt(count - 1) instanceof StatusBarView) {
        decorView.removeViewAt(count - 1);
        ViewGroup rootView = (ViewGroup) ((ViewGroup) activity.findViewById(android.R.id.content)).getChildAt(0);
        rootView.setPadding(0, 0, 0, 0);
    }
}
 
開發者ID:joelan,項目名稱:ClouldReader,代碼行數:11,代碼來源:StatusBarUtil.java

示例4: swapViewGroupChildren

import android.view.ViewGroup; //導入方法依賴的package包/類
public static void swapViewGroupChildren(ViewGroup viewGroup, View firstView, View secondView) {
    int firstIndex = viewGroup.indexOfChild(firstView);
    int secondIndex = viewGroup.indexOfChild(secondView);
    if (firstIndex < secondIndex) {
        viewGroup.removeViewAt(secondIndex);
        viewGroup.removeViewAt(firstIndex);
        viewGroup.addView(secondView, firstIndex);
        viewGroup.addView(firstView, secondIndex);
    } else {
        viewGroup.removeViewAt(firstIndex);
        viewGroup.removeViewAt(secondIndex);
        viewGroup.addView(firstView, secondIndex);
        viewGroup.addView(secondView, firstIndex);
    }
}
 
開發者ID:HanyeeWang,項目名稱:GeekZone,代碼行數:16,代碼來源:AppUtils.java

示例5: addTranslucentView

import android.view.ViewGroup; //導入方法依賴的package包/類
/**
 * 添加半透明矩形條
 *
 * @param activity       需要設置的 activity
 * @param statusBarAlpha 透明值
 */
private static void addTranslucentView(Activity activity, int statusBarAlpha) {
    ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content);
    // 移除半透明矩形,以免疊加
    if (contentView.getChildCount() > 1) {
        contentView.removeViewAt(1);
    }
    contentView.addView(createTranslucentStatusBarView(activity, statusBarAlpha));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:15,代碼來源:StatusBarUtil.java

示例6: build

import android.view.ViewGroup; //導入方法依賴的package包/類
/**
 * 此方法自動會處理, 請勿手動調用
 */
public void build(SwipeRecycleViewItemLayout itemLayout) {
    int targetMenuSize = mMenuList.size();
    ViewGroup menuLayout = itemLayout.getMenuView();
    int menuSize = menuLayout.getChildCount();

    if (menuSize > targetMenuSize) {
        for (int i = menuSize - 1; i > targetMenuSize - 1; i--) {
            menuLayout.removeViewAt(i);
        }
    }

    for (int i = menuLayout.getChildCount(); i < targetMenuSize; i++) {
        RTextView textView = new RTextView(mContext);
        textView.setBackgroundResource(R.drawable.base_bg_selector);
        menuLayout.addView(textView, new ViewGroup.LayoutParams(-2, -1));
    }

    for (int i = 0; i < targetMenuSize; i++) {
        View childAt = menuLayout.getChildAt(i);
        MenuItem menuItem = mMenuList.get(i);

        childAt.setPadding(menuItem.paddLeft, 0, menuItem.paddRight, 0);

        childAt.setOnClickListener(menuItem.clickListener);
        if (childAt instanceof TextView) {
            ((TextView) childAt).setText(menuItem.title);
            ((TextView) childAt).setTextColor(menuItem.textColor);
            ((TextView) childAt).setGravity(menuItem.gravity);
        }
        if (childAt instanceof RTextView) {
            ((RTextView) childAt).setRBackgroundColor(menuItem.bgColor);
        }
    }
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:38,代碼來源:MenuBuilder.java

示例7: dismiss

import android.view.ViewGroup; //導入方法依賴的package包/類
private void dismiss() {
  if (mDialog != null) {
    mDialog.dismiss();
    mDialog = null;

    // We need to remove the mHostView from the parent
    // It is possible we are dismissing this dialog and reattaching the hostView to another
    ViewGroup parent = (ViewGroup) mHostView.getParent();
    parent.removeViewAt(0);
  }
}
 
開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:12,代碼來源:ReactModalHostView.java

示例8: setTransparent

import android.view.ViewGroup; //導入方法依賴的package包/類
public static void setTransparent(Activity activity, View needOffsetView) {

        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
            return;
        }

        ViewGroup contentView = (ViewGroup) activity.findViewById(android.R.id.content);
        if (contentView.getChildAt(0) == null) {
            return;
        }
        else if (contentView.getChildCount() > 1 && contentView.getChildAt(1) instanceof StatusBarView) {
            contentView.removeViewAt(1);
        }
        if (contentView.getChildAt(0) instanceof DrawerLayout) {
            // 讓DrawerLayout中的布局內容可以延伸到狀態欄
            // 為了實現上述效果,設置DrawerLayout以及兩個子View的fitsSystemWindows為false
            // 這個帶來了一個問題:
            // DrawerLayout的內容布局會從屏幕最上方開始繪製,
            // 所以需要下移避免被狀態欄遮擋的布局,手動設置marginTop。
            DrawerLayout drawerLayout = (DrawerLayout) contentView.getChildAt(0);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
                activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                activity.getWindow().setStatusBarColor(Color.TRANSPARENT);
            } else {
                activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            }

            ViewGroup drawerLayoutContent = (ViewGroup) drawerLayout.getChildAt(0);
            //如果DrawerLayout的內容布局第一個子View是我們自己的StatusBarView就將它reomve。
            if (drawerLayoutContent.getChildAt(0) instanceof StatusBarView) {
                drawerLayoutContent.removeViewAt(0);
            }

            View drawerLayoutContentReal = drawerLayoutContent.getChildAt(0);

            // 內容布局不是 LinearLayout 時,清除多餘的StatusBarHeight。
            if (!(drawerLayoutContent instanceof LinearLayout) &&
                    drawerLayoutContentReal != null &&
                    drawerLayoutContentReal.getTag(R.id.tag_top) != null &&
                    drawerLayoutContentReal.getTag(R.id.tag_top).equals(TAG_ADD_TOP)) {
                drawerLayoutContentReal.setPadding(
                        drawerLayoutContentReal.getPaddingLeft(),
                        drawerLayoutContentReal.getPaddingTop() - getStatusBarHeight(activity),
                        drawerLayoutContentReal.getPaddingRight(),
                        drawerLayoutContentReal.getPaddingBottom()
                );
                drawerLayoutContentReal.setTag(R.id.tag_top, TAG_REMOVE_TOP);
            }

            // 設置屬性
            setDrawerLayoutProperty(drawerLayout, drawerLayoutContent);

        } else if (contentView.getChildAt(0) instanceof CoordinatorLayout) {

            transparentStatusBar(activity);
            setRootViewPaddingTop(activity, PaddingTop.removePaddingTop);

        } else {
            transparentStatusBar(activity);

            ViewCompat.setFitsSystemWindows(contentView.getChildAt(0), false);
            ViewCompat.requestApplyInsets(contentView.getChildAt(0));
        }

        if (needOffsetView != null && needOffsetView.getTag(R.id.tag_need_offset) == null) {

            ViewGroup.MarginLayoutParams layoutParams =
                    (ViewGroup.MarginLayoutParams) needOffsetView.getLayoutParams();
            layoutParams.setMargins(
                    layoutParams.leftMargin,
                    layoutParams.topMargin + getStatusBarHeight(activity),
                    layoutParams.rightMargin,
                    layoutParams.bottomMargin);

            needOffsetView.setTag(R.id.tag_need_offset, TAG_NEED_OFFNET);
        }
    }
 
開發者ID:ghnor,項目名稱:StatusBarFits,代碼行數:79,代碼來源:StatusBarFits.java

示例9: onCreateView

import android.view.ViewGroup; //導入方法依賴的package包/類
@Override
public final View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
	View layout = super.onCreateView(inflater, container, savedInstanceState);

	ListView lv = (ListView) layout.findViewById(android.R.id.list);
	ViewGroup parent = (ViewGroup) lv.getParent();

	// Remove ListView and add PullToRefreshListView in its place
	int lvIndex = parent.indexOfChild(lv);
	parent.removeViewAt(lvIndex);
	mPullToRefreshListView = onCreatePullToRefreshListView(inflater, savedInstanceState);
	parent.addView(mPullToRefreshListView, lvIndex, lv.getLayoutParams());

	return layout;
}
 
開發者ID:SavorGit,項目名稱:Hotspot-master-devp,代碼行數:16,代碼來源:PullToRefreshBaseListFragment.java

示例10: destroyItem

import android.view.ViewGroup; //導入方法依賴的package包/類
public void destroyItem(final ViewGroup container, final int position, final Object object) {

        for (int i = 0; i < container.getChildCount(); i++) {
            if (((AttachmentPreview) container.getChildAt(i)).getAttachment() == object) {
                container.removeViewAt(i);
                break;
            }
        }
    }
 
開發者ID:PacktPublishing,項目名稱:Hands-On-Android-UI-Development,代碼行數:10,代碼來源:AttachmentPreviewAdapter.java

示例11: clearPreviousSetting

import android.view.ViewGroup; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.KITKAT)
private static void clearPreviousSetting(Activity activity)
{
    ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
    int count = decorView.getChildCount();
    if(count > 0 && decorView.getChildAt(count - 1) instanceof StatusBarView)
    {
        decorView.removeViewAt(count - 1);
        ViewGroup rootView = (ViewGroup) ((ViewGroup) activity
                .findViewById(android.R.id.content)).getChildAt(0);
        rootView.setPadding(0, 0, 0, 0);
    }
}
 
開發者ID:Ayvytr,項目名稱:EasyAndroid,代碼行數:14,代碼來源:BarTool.java

示例12: addTranslucentView

import android.view.ViewGroup; //導入方法依賴的package包/類
/**
 * 添加半透明矩形條
 *
 * @param activity 需要設置的 activity
 * @param statusBarAlpha 透明值
 */
private static void addTranslucentView(Activity activity, int statusBarAlpha) {
    ViewGroup contentView = (ViewGroup) activity
            .findViewById(android.R.id.content);
    // 移除半透明矩形,以免疊加
    if (contentView.getChildCount() > 1) {
        contentView.removeViewAt(1);
    }
    contentView
            .addView(createTranslucentStatusBarView(activity, statusBarAlpha));
}
 
開發者ID:imliujun,項目名稱:LJFramework,代碼行數:17,代碼來源:StatusBarUtil.java

示例13: attachTrackerFrameLayout

import android.view.ViewGroup; //導入方法依賴的package包/類
public void attachTrackerFrameLayout(Activity activity) {
    // this is a problem: several activity exist in the TabActivity
    if (activity == null || activity instanceof TabActivity) {
        return;
    }


    // exist android.R.id.content not found crash
    try {
        ViewGroup container = (ViewGroup) activity.findViewById(android.R.id.content);

        if (container == null) {
            return;
        }

        if (container.getChildCount() > 0) {
            View root = container.getChildAt(0);
            if (root instanceof TrackerFrameLayout) {
                TrackerLog.d("no attachTrackerFrameLayout " + activity.toString());
            } else {
                TrackerFrameLayout trackerFrameLayout = new TrackerFrameLayout(activity);

                while (container.getChildCount() > 0) {
                    View view = container.getChildAt(0);
                    container.removeViewAt(0);
                    trackerFrameLayout.addView(view, view.getLayoutParams());
                }

                container.addView(trackerFrameLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
            }
        }
    } catch (Exception e) {
        TrackerLog.e(e.toString());
    }

}
 
開發者ID:alibaba,項目名稱:android_viewtracker,代碼行數:37,代碼來源:TrackerManager.java


注:本文中的android.view.ViewGroup.removeViewAt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。