Java Code Examples for android.widget.LinearLayout#getMeasuredWidth()
The following examples show how to use
android.widget.LinearLayout#getMeasuredWidth() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MonitorFragment.java From onpc with GNU General Public License v3.0 | 6 votes |
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(); } }
Example 2
Source File: CustomListView.java From AndroidStudyDemo with GNU General Public License v2.0 | 5 votes |
/** * 添加下拉刷新的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; }
Example 3
Source File: PullToRefreshListView.java From zhangshangwuda with Apache License 2.0 | 5 votes |
/*** * 初始化头部 */ 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); }
Example 4
Source File: PullToRefreshListView.java From wakao-app with MIT License | 4 votes |
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); }
Example 5
Source File: BootstrapDropDown.java From Android-Bootstrap with MIT License | 4 votes |
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; }