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


Java LinearLayout.getChildCount方法代码示例

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


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

示例1: setGiftLayout

import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
 * @param giftLayoutParent 存放礼物控件的父容器
 * @param giftLayoutNums   礼物控件的数量
 * @return
 */
public GiftControl setGiftLayout(LinearLayout giftLayoutParent, @NonNull int giftLayoutNums) {
    if (giftLayoutNums <= 0) {
        throw new IllegalArgumentException("GiftFrameLayout数量必须大于0");
    }
    if (giftLayoutParent.getChildCount() > 0) {//如果父容器没有子孩子,就进行添加
        return this;
    }
    mGiftLayoutParent = giftLayoutParent;
    mGiftLayoutMaxNums = giftLayoutNums;
    LayoutTransition transition = new LayoutTransition();
    transition.setAnimator(LayoutTransition.CHANGE_APPEARING,
            transition.getAnimator(LayoutTransition.CHANGE_APPEARING));
    transition.setAnimator(LayoutTransition.APPEARING,
            transition.getAnimator(LayoutTransition.APPEARING));
    transition.setAnimator(LayoutTransition.DISAPPEARING,
            transition.getAnimator(LayoutTransition.CHANGE_APPEARING));
    transition.setAnimator(LayoutTransition.CHANGE_DISAPPEARING,
            transition.getAnimator(LayoutTransition.DISAPPEARING));
    mGiftLayoutParent.setLayoutTransition(transition);

    return this;
}
 
开发者ID:DyncKathline,项目名称:LiveGiftLayout,代码行数:28,代码来源:GiftControl.java

示例2: recycleItems

import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
 * Recycles items from specified layout.
 * There are saved only items not included to specified range.
 * All the cached items are removed from original layout.
 * 
 * @param layout the layout containing items to be cached
 * @param firstItem the number of first item in layout
 * @param range the range of current wheel items 
 * @return the new value of first item number
 */
public int recycleItems(LinearLayout layout, int firstItem, ItemsRange range) {
	int index = firstItem;
	for (int i = 0; i < layout.getChildCount();) {
		if (!range.contains(index)) {
			recycleView(layout.getChildAt(i), index);
			layout.removeViewAt(i);
			if (i == 0) { // first item
				firstItem++;
			}
		} else {
			i++; // go to next item
		}
		index++;
	}
	return firstItem;
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:27,代码来源:WheelRecycle.java

示例3: makeGallerySwitchBackGround

import android.widget.LinearLayout; //导入方法依赖的package包/类
private void makeGallerySwitchBackGround(LinearLayout gallerySwtichLayout, int count) {
    int childCount = gallerySwtichLayout.getChildCount();
    if (count > childCount) {
        count -= childCount;
        for (int i = 0; i < count; i++) {
            ImageView itemImageView = new ImageView(getActivity());
            itemImageView.setLayoutParams(new LayoutParams(-2, -2));
            itemImageView.setImageResource(2130838158);
            itemImageView.setPadding(5, 0, 5, 0);
            gallerySwtichLayout.addView(itemImageView, childCount + i);
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:14,代码来源:TopRecommendFragment.java

示例4: recycleItems

import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
 * Recycles items from specified layout.
 * There are saved only items not included to specified range.
 * All the cached items are removed from original layout.
 * 
 * @param layout the layout containing items to be cached
 * @param firstItem the number of first item in layout
 * @param range the range of current wheel items 
 * @return the new value of first item number
 */
public int recycleItems(LinearLayout layout, int firstItem, ItemsRange range) {
	int index = firstItem;
	for (int i = 0; i < layout.getChildCount();) {
		if (!range.contains(index)) {
			recycleView(layout.getChildAt(i), index);
			layout.removeViewAt(i);
			if (i == 0) { // first item
				firstItem++;
			}
		} else {
			i++;
		}
		index++;
	}
	return firstItem;
}
 
开发者ID:socoolby,项目名称:CoolClock,代码行数:27,代码来源:WheelRecycle.java

示例5: recycleItems

import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
 * Recycles items from specified layout.
 * There are saved only items not included to specified range.
 * All the cached items are removed from original layout.
 *
 * @param layout the layout containing items to be cached
 * @param firstItem the number of first item in layout
 * @param range the range of current wheel items
 * @return the new value of first item number
 */
public int recycleItems(LinearLayout layout, int firstItem, ItemsRange range) {
	int index = firstItem;
	for (int i = 0; i < layout.getChildCount();) {
		if (!range.contains(index)) {
			recycleView(layout.getChildAt(i), index);
			layout.removeViewAt(i);
			if (i == 0) { // first item
				firstItem++;
			}
		} else {
			i++; // go to next item
		}
		index++;
	}
	return firstItem;
}
 
开发者ID:ArtifexSoftware,项目名称:mupdf-android-viewer-nui,代码行数:27,代码来源:WheelRecycle.java

示例6: ViewHolderFunc

import android.widget.LinearLayout; //导入方法依赖的package包/类
public ViewHolderFunc(View itemView) {
    super(itemView);

    LinearLayout root = (LinearLayout) itemView.findViewById(R.id.content_container);
    for (int i = 0; i < root.getChildCount(); i++) {
        for (int z = 0; z < ((ViewGroup) root.getChildAt(i)).getChildCount(); z++) {
            ((ViewGroup) root.getChildAt(i)).getChildAt(z).setOnClickListener(this);
        }
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:ViewHolderFunc.java

示例7: getPermissionsView

import android.widget.LinearLayout; //导入方法依赖的package包/类
public View getPermissionsView(int which) {
    LinearLayout permsView = (LinearLayout) inflater.inflate(R.layout.app_perms_summary, null);
    LinearLayout displayList = (LinearLayout) permsView.findViewById(R.id.perms_list);
    View noPermsView = permsView.findViewById(R.id.no_permissions);

    displayPermissions(permGroupsList, displayList, which);
    if (displayList.getChildCount() <= 0) {
        noPermsView.setVisibility(View.VISIBLE);
    }

    return permsView;
}
 
开发者ID:uhuru-mobile,项目名称:mobile-store,代码行数:13,代码来源:AppSecurityPermissions.java

示例8: removeChild

import android.widget.LinearLayout; //导入方法依赖的package包/类
public void removeChild(String childId) {
    int containerCount = linearLayout.getChildCount();

    LinearLayout lastContainer = null;
    List<LinearLayout> containerList = new ArrayList<>();
    for (int i = 0; i < containerCount; i++) {
        LinearLayout container = (LinearLayout) linearLayout.getChildAt(i);
        containerList.add(container);
    }
    for (LinearLayout resultContainer : containerList) {
        if (lastContainer == null) {
            LinearLayout child = (LinearLayout) resultContainer.findViewWithTag(childId);
            if (child != null) {
                resultContainer.removeView(child);
                if (resultContainer.getChildCount() == 0) {
                    linearLayout.removeView(resultContainer);
                    break;
                } else {
                    lastContainer = resultContainer;
                }
            }
        } else {
            View view = resultContainer.getChildAt(0);
            resultContainer.removeView(view);
            lastContainer.addView(view);
            if (resultContainer.getChildCount() == 0) {
                linearLayout.removeView(resultContainer);
                break;
            } else {
                lastContainer = resultContainer;
            }
        }
    }
}
 
开发者ID:hushengjun,项目名称:FastAndroid,代码行数:35,代码来源:CallUserGridView.java

示例9: dismiss

import android.widget.LinearLayout; //导入方法依赖的package包/类
/**
 * Animate the views too look more lively
 */
public void dismiss()
{
    LinearLayout layout = (LinearLayout) getChildAt(0);

    for (int i = 0; i < layout.getChildCount(); i++)
    {
        View v = layout.getChildAt(i);
        v.setScaleX(1);
        v.setScaleY(1);
        v.animate().cancel();
        v.animate().translationY(isReversed ? -v.getHeight() :v.getHeight())
                .scaleX(0).scaleY(0).setDuration(100)
                .setStartDelay(80 * i)
                .setInterpolator(null)
                .start();
    }
    // hide view when finish animating
    new Handler().postDelayed(new Runnable()
    {
        @Override
        public void run()
        {
            manager.dismiss();
        }
    }, 150 * layout.getChildCount());
}
 
开发者ID:Emadoki,项目名称:edslider,代码行数:30,代码来源:EdSliderView.java

示例10: setCurrentItem

import android.widget.LinearLayout; //导入方法依赖的package包/类
public void setCurrentItem(int item) {
    if (this.mViewPager != null) {
        if (!(item == -1 || this.mSelectedTabIndex == item)) {
            this.mViewPager.setCurrentItem(item);
        }
        this.mSelectedTabIndex = item;
        int tabCount = this.mTabLayout.getChildCount();
        int i = 0;
        while (i < tabCount) {
            LinearLayout childLayout = (LinearLayout) this.mTabLayout.getChildAt(i);
            for (int j = 0; j < childLayout.getChildCount(); j++) {
                boolean isSelected = i == item;
                View view = childLayout.getChildAt(j);
                if (view instanceof TabView) {
                    view.setSelected(isSelected);
                    if (isSelected) {
                        animateToTab(item);
                        ((TabView) view).setTextColor(this.mContext.getResources().getColor(2131493202));
                    } else {
                        ((TabView) view).setTextColor(this.mContext.getResources().getColor(2131493237));
                    }
                } else if (isSelected) {
                    view.setBackgroundColor(this.mContext.getResources().getColor(2131493202));
                } else {
                    view.setBackgroundDrawable(null);
                }
            }
            i++;
        }
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:32,代码来源:MyMessageTabPageIndicator.java

示例11: resetBarValues

import android.widget.LinearLayout; //导入方法依赖的package包/类
public void resetBarValues() {

		if (oldFrameLayout != null)
			removeClickedBar();

		final int barsCount = ((LinearLayout) this.getChildAt(0)).getChildCount();

		for (int i = 0; i < barsCount; i++) {

			FrameLayout rootFrame = (FrameLayout) ((LinearLayout) this.getChildAt(0)).getChildAt(i);
			int rootChildCount = rootFrame.getChildCount();

			for (int j = 0; j < rootChildCount; j++) {

				View childView = rootFrame.getChildAt(j);

				if (childView instanceof LinearLayout) {
					//bar
					LinearLayout barContainerLinear = ((LinearLayout) childView);
					int barContainerCount = barContainerLinear.getChildCount();

					for (int k = 0; k < barContainerCount; k++) {

						View view = barContainerLinear.getChildAt(k);

						if (view instanceof Bar) {
							BarAnimation anim = new BarAnimation(((Bar) view), 0, (int) (mDataList.get(i).getBarValue() * 100));
							anim.setDuration(250);
							((Bar) view).startAnimation(anim);
						}
					}
				}


			}
		}
		isBarsEmpty = false;
	}
 
开发者ID:hadiidbouk,项目名称:ChartProgressBar-Android,代码行数:39,代码来源:ChartProgressBar.java

示例12: removeBarValues

import android.widget.LinearLayout; //导入方法依赖的package包/类
public void removeBarValues() {

		if (oldFrameLayout != null)
			removeClickedBar();

		final int barsCount = ((LinearLayout) this.getChildAt(0)).getChildCount();

		for (int i = 0; i < barsCount; i++) {

			FrameLayout rootFrame = (FrameLayout) ((LinearLayout) this.getChildAt(0)).getChildAt(i);
			int rootChildCount = rootFrame.getChildCount();

			for (int j = 0; j < rootChildCount; j++) {

				View childView = rootFrame.getChildAt(j);

				if (childView instanceof LinearLayout) {
					//bar
					LinearLayout barContainerLinear = ((LinearLayout) childView);
					int barContainerCount = barContainerLinear.getChildCount();

					for (int k = 0; k < barContainerCount; k++) {

						View view = barContainerLinear.getChildAt(k);

						if (view instanceof Bar) {
							BarAnimation anim = new BarAnimation(((Bar) view), (int) (mDataList.get(i).getBarValue() * 100), 0);
							anim.setDuration(250);
							((Bar) view).startAnimation(anim);
						}
					}
				}
			}


		}
		isBarsEmpty = true;
	}
 
开发者ID:hadiidbouk,项目名称:ChartProgressBar-Android,代码行数:39,代码来源:ChartProgressBar.java

示例13: onCreate

import android.widget.LinearLayout; //导入方法依赖的package包/类
@Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tab_layout);
        mTabLayout = (TabLayout) findViewById(R.id.tabLayout);

        // 手动创建Tab
//        for (int i = 0; i < title.length; i++) {
//            TabLayout.Tab tab = mTabLayout.newTab();
//            tab.setText(title[i]);
////            tab.setIcon(R.mipmap.ic_launcher);//icon会显示在文字上面
//            mTabLayout.addTab(tab);
//        }

        // TabLayout与ViewPager结合使用
        mViewPager = (ViewPager) findViewById(R.id.viewPager);
        MyViewPagerAdapter adapter = new MyViewPagerAdapter(getSupportFragmentManager());
        mViewPager.setAdapter(adapter);
//        // 适配器必须重写getPageTitle()方法
//        mTabLayout.setTabsFromPagerAdapter(adapter);
//        // 监听TabLayout的标签选择,当标签选中时ViewPager切换
//        mTabLayout.setOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager));
//        // 监听ViewPager的页面切换,当页面切换时TabLayout的标签跟着切换
//        mViewPager.setOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(mTabLayout));
        // 关联TabLayout与ViewPager,且适配器必须重写getPageTitle()方法
        mTabLayout.setupWithViewPager(mViewPager);


        mLinearLayout = (LinearLayout) mTabLayout.getChildAt(0);
        // 在所有子控件的中间显示分割线(还可能只显示顶部、尾部和不显示分割线)
        mLinearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
        // 设置分割线的距离本身(LinearLayout)的内间距
        mLinearLayout.setDividerPadding(50);
        // 设置分割线的样式
        mLinearLayout.setDividerDrawable(ContextCompat.getDrawable(this, R.drawable.divider_vertical));
        mLinearLayout.setBackgroundColor(getResources().getColor(R.color.colorPrimaryDark));


        // 为TabLayout设置不同状态下的字体大小(并不能成功)
//        for (int i = 0; i < mTabLayout.getTabCount(); i++) {
//            ((TextView) ((LinearLayout) mLinearLayout.getChildAt(i)).getChildAt(1)).setTextSize(10);
////            ((TextView) ((LinearLayout) ((LinearLayout) mTabLayout.getChildAt(0)).getChildAt(i)).getChildAt(0)).setTextSize(12);
//        }
//        ((TextView) ((LinearLayout) mLinearLayout.getChildAt(mTabLayout.getSelectedTabPosition())).getChildAt(1)).setTextSize(30);
//
//        mTabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
//            @Override
//            public void onTabSelected(TabLayout.Tab tab) {
//                ((TextView) ((LinearLayout) mLinearLayout.getChildAt(tab.getPosition())).getChildAt(1)).setTextSize(30);
//            }
//
//            @Override
//            public void onTabUnselected(TabLayout.Tab tab) {
//                ((TextView) ((LinearLayout) mLinearLayout.getChildAt(tab.getPosition())).getChildAt(1)).setTextSize(10);
//            }
//
//            @Override
//            public void onTabReselected(TabLayout.Tab tab) {
//
//            }
//        });


        // 自定义指示器(Indicator)的“长度”的两种方法
        // 方法一:反射
//        setIndicator(mTabLayout,10,10);
        // 方法二:查找子控件
        int left = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, Resources.getSystem().getDisplayMetrics());
        int right = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, Resources.getSystem().getDisplayMetrics());
        for (int i = 0; i < mLinearLayout.getChildCount(); i++) {
            View tabView = mLinearLayout.getChildAt(0);
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1);
            params.leftMargin = left;
            params.rightMargin = right;
            tabView.setLayoutParams(params);
        }
    }
 
开发者ID:GitLqr,项目名称:MaterialDesignDemo,代码行数:78,代码来源:TabLayoutActivity.java

示例14: setState

import android.widget.LinearLayout; //导入方法依赖的package包/类
private void setState(LinearLayout layout, boolean selected) {
    for (int i = 0; i < layout.getChildCount(); i++) {
        layout.getChildAt(i).setSelected(selected);
    }
}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:6,代码来源:ShakePresentActivity.java

示例15: disableBar

import android.widget.LinearLayout; //导入方法依赖的package包/类
public void disableBar(int index) {

		final int barsCount = ((LinearLayout) this.getChildAt(0)).getChildCount();

		for (int i = 0; i < barsCount; i++) {

			FrameLayout rootFrame = (FrameLayout) ((LinearLayout) this.getChildAt(0)).getChildAt(i);

			int rootChildCount = rootFrame.getChildCount();

			for (int j = 0; j < rootChildCount; j++) {

				if ((int) rootFrame.getTag() != index)
					continue;

				rootFrame.setEnabled(false);
				rootFrame.setClickable(false);

				View childView = rootFrame.getChildAt(j);
				if (childView instanceof LinearLayout) {
					//bar
					LinearLayout barContainerLinear = ((LinearLayout) childView);
					int barContainerCount = barContainerLinear.getChildCount();

					for (int k = 0; k < barContainerCount; k++) {

						View view = barContainerLinear.getChildAt(k);

						if (view instanceof Bar) {

							Bar bar = (Bar) view;

							LayerDrawable layerDrawable = (LayerDrawable) bar.getProgressDrawable();
							layerDrawable.mutate();

							ScaleDrawable scaleDrawable = (ScaleDrawable) layerDrawable.getDrawable(1);

							GradientDrawable progressLayer = (GradientDrawable) scaleDrawable.getDrawable();

							if (progressLayer != null) {

								if (mProgressDisableColor > 0)
									progressLayer.setColor(ContextCompat.getColor(mContext, mProgressDisableColor));
								else
									progressLayer.setColor(ContextCompat.getColor(mContext, android.R.color.darker_gray));
							}
						} else {
							TextView titleTxtView = (TextView) view;
							if (mProgressDisableColor > 0)
								titleTxtView.setTextColor(ContextCompat.getColor(mContext, mProgressDisableColor));
							else
								titleTxtView.setTextColor(ContextCompat.getColor(mContext, android.R.color.darker_gray));
						}
					}
				}
			}
		}
	}
 
开发者ID:hadiidbouk,项目名称:ChartProgressBar-Android,代码行数:59,代码来源:ChartProgressBar.java


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