android.widget.LinearLayout#getMeasuredWidth ( )源码实例Demo

下面列出了android.widget.LinearLayout#getMeasuredWidth ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: onpc   文件: MonitorFragment.java
private void updateListeningModeLayout()
{
    listeningModeLayout.requestLayout();
    if (listeningModeLayout.getChildCount() == 1)
    {
        final LinearLayout l = (LinearLayout) listeningModeLayout.getChildAt(0);
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
                FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
        if (l.getMeasuredWidth() < listeningModeLayout.getMeasuredWidth())
        {
            params.gravity = Gravity.CENTER;
        }
        l.setLayoutParams(params);
        l.requestLayout();
    }
}
 
源代码2 项目: AndroidStudyDemo   文件: CustomListView.java
/**
 * 添加下拉刷新的HeadView 
 * @date 2013-11-11 下午9:48:26
 * @change JohnWatson
 * @version 1.0
 */
private void addHeadView() {
	mHeadView = (LinearLayout) mInflater.inflate(R.layout.head, null);

	mArrowImageView = (ImageView) mHeadView
			.findViewById(R.id.head_arrowImageView);
	mArrowImageView.setMinimumWidth(70);
	mArrowImageView.setMinimumHeight(50);
	mProgressBar = (ProgressBar) mHeadView
			.findViewById(R.id.head_progressBar);
	mTipsTextView = (TextView) mHeadView.findViewById(
			R.id.head_tipsTextView);
	mLastUpdatedTextView = (TextView) mHeadView
			.findViewById(R.id.head_lastUpdatedTextView);

	measureView(mHeadView);
	mHeadViewHeight = mHeadView.getMeasuredHeight();
	mHeadViewWidth = mHeadView.getMeasuredWidth();
	
	mHeadView.setPadding(0, -1 * mHeadViewHeight, 0, 0);
	mHeadView.invalidate();

	Log.v("size", "width:" + mHeadViewWidth + " height:"
			+ mHeadViewHeight);

	addHeaderView(mHeadView, null, false);
	
	mHeadState = DONE;
}
 
源代码3 项目: zhangshangwuda   文件: PullToRefreshListView.java
/***
 * 初始化头部
 */
private void initHeadView() {

	inflater = LayoutInflater.from(context);
	mHeadView = (LinearLayout) inflater.inflate(
			R.layout.pulldownlistview_head, null);

	mArrowImageView = (ImageView) mHeadView
			.findViewById(R.id.pulldownlistview_head_arrow_ImageView);
	mArrowImageView.setMinimumWidth(50);
	mArrowImageView.setMinimumHeight(50);
	mHeadProgressBar = (ProgressBar) mHeadView
			.findViewById(R.id.pulldownlistview_head_progressBar);
	mRefreshTextview = (TextView) mHeadView
			.findViewById(R.id.pulldownlistview_head_tips_TextView);
	mLastUpdateTextView = (TextView) mHeadView
			.findViewById(R.id.pulldownlistview_head_lastUpdated_TextView);

	headContentOriginalTopPadding = mHeadView.getPaddingTop();

	measureView(mHeadView);
	headContentHeight = mHeadView.getMeasuredHeight();
	headContentWidth = mHeadView.getMeasuredWidth();

	mHeadView.setPadding(mHeadView.getPaddingLeft(),
			-1 * headContentHeight, mHeadView.getPaddingRight(),
			mHeadView.getPaddingBottom());
	mHeadView.invalidate();

	// LOG.D("初始高度:"+headContentHeight);
	// LOG.D("初始TopPad:"+headContentOriginalTopPadding);

	addHeaderView(mHeadView);
	setOnScrollListener(this);
}
 
源代码4 项目: wakao-app   文件: PullToRefreshListView.java
private void init(Context context) {   
	//设置滑动效果
    animation = new RotateAnimation(0, -180,  
            RotateAnimation.RELATIVE_TO_SELF, 0.5f,  
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);  
    animation.setInterpolator(new LinearInterpolator());  
    animation.setDuration(100);  
    animation.setFillAfter(true);  
  
    reverseAnimation = new RotateAnimation(-180, 0,  
            RotateAnimation.RELATIVE_TO_SELF, 0.5f,  
            RotateAnimation.RELATIVE_TO_SELF, 0.5f);  
    reverseAnimation.setInterpolator(new LinearInterpolator());  
    reverseAnimation.setDuration(100);  
    reverseAnimation.setFillAfter(true);  
    
    inflater = LayoutInflater.from(context);  
    headView = (LinearLayout) inflater.inflate(R.layout.pull_to_refresh_head, null);  
  
    arrowImageView = (ImageView) headView.findViewById(R.id.head_arrowImageView);  
    arrowImageView.setMinimumWidth(50);  
    arrowImageView.setMinimumHeight(50);  
    progressBar = (ProgressBar) headView.findViewById(R.id.head_progressBar);  
    tipsTextview = (TextView) headView.findViewById(R.id.head_tipsTextView);  
    lastUpdatedTextView = (TextView) headView.findViewById(R.id.head_lastUpdatedTextView);  
    
    headContentOriginalTopPadding = headView.getPaddingTop();  
    
    measureView(headView);  
    headContentHeight = headView.getMeasuredHeight();  
    headContentWidth = headView.getMeasuredWidth(); 
    
    headView.setPadding(headView.getPaddingLeft(), -1 * headContentHeight, headView.getPaddingRight(), headView.getPaddingBottom());  
    headView.invalidate();  

    //System.out.println("初始高度:"+headContentHeight); 
    //System.out.println("初始TopPad:"+headContentOriginalTopPadding);
    
    addHeaderView(headView);        
    setOnScrollListener(this); 
}
 
源代码5 项目: Android-Bootstrap   文件: BootstrapDropDown.java
private ScrollView createDropDownView() {
    final LinearLayout dropdownView = new LinearLayout(getContext());
    ScrollView scrollView = new ScrollView(getContext());
    int clickableChildCounter = 0;

    dropdownView.setOrientation(LinearLayout.VERTICAL);
    int height = (int) (itemHeight * bootstrapSize);
    LayoutParams childParams = new LayoutParams(LayoutParams.MATCH_PARENT, height);

    for (String text : dropdownData) {
        TextView childView = new TextView(getContext());
        childView.setGravity(Gravity.CENTER_VERTICAL);
        childView.setLayoutParams(childParams);

        int padding = (int) (baselineItemLeftPadding * bootstrapSize);
        childView.setPadding(padding, 0, padding, 0);
        childView.setTextSize(baselineDropDownViewFontSize * bootstrapSize);
        childView.setTextColor(ColorUtils.resolveColor(android.R.color.black, getContext()));

        Drawable background = getContext().obtainStyledAttributes(null, new int[]{
                android.R.attr.selectableItemBackground}, 0, 0)
                                        .getDrawable(0);
        ViewUtils.setBackgroundDrawable(childView, background);

        childView.setTextColor(BootstrapDrawableFactory.bootstrapDropDownViewText(getContext()));
        childView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dropdownWindow.dismiss();
                if (onDropDownItemClickListener != null) {
                    onDropDownItemClickListener.onItemClick(dropdownView, v, v.getId());
                }
            }
        });

        if (Pattern.matches(SEARCH_REGEX_HEADER, text)) {
            childView.setText(text.replaceFirst(REPLACE_REGEX_HEADER, ""));
            childView.setTextSize((baselineDropDownViewFontSize - 2F) * bootstrapSize);
            childView.setClickable(false);
            childView.setTextColor(ColorUtils.resolveColor(R.color.bootstrap_gray_light,
                                                           getContext()));
        }
        else if (Pattern.matches(SEARCH_REGEX_SEPARATOR, text)) {
            childView = new DividerView(getContext());
            childView.setClickable(false);
            childView.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 3));
        }
        else if (Pattern.matches(SEARCH_REGEX_DISABLED, text)) {
            childView.setEnabled(false);
            childView.setId(clickableChildCounter++);
            childView.setText(text.replaceFirst(REPLACE_REGEX_DISABLED, ""));
        }
        else {
            childView.setText(text);
            childView.setId(clickableChildCounter++);
        }
        dropdownView.addView(childView);
    }

    dropdownView.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
    dropDownViewHeight = dropdownView.getMeasuredHeight();
    dropDownViewWidth = dropdownView.getMeasuredWidth();

    scrollView.setVerticalScrollBarEnabled(false);
    scrollView.setHorizontalScrollBarEnabled(false);
    scrollView.addView(dropdownView);

    cleanData();
    return scrollView;
}