当前位置: 首页>>代码示例>>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;未经允许,请勿转载。