List of usage examples for android.view ViewGroup getPaddingRight
public int getPaddingRight()
From source file:com.cicada.startup.common.ui.view.indicator.ViewPagerIndicator.java
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); if (!allowWidthFull) { return;/* w w w . ja v a 2 s . c o m*/ } setMeasuredDimension(getMeasuredWidth(), getMeasuredHeight() + slidingBlockHeight); ViewGroup tabsLayout = getTabsLayout(); if (tabsLayout == null || tabsLayout.getMeasuredWidth() >= getMeasuredWidth()) return; if (tabsLayout.getChildCount() <= 0) return; if (tabViews == null) { tabViews = new ArrayList<View>(); } else { tabViews.clear(); } for (int w = 0; w < tabsLayout.getChildCount(); w++) { tabViews.add(tabsLayout.getChildAt(w)); } adjustChildWidthWithParent(tabViews, getMeasuredWidth() - tabsLayout.getPaddingLeft() - tabsLayout.getPaddingRight(), widthMeasureSpec, heightMeasureSpec); super.onMeasure(widthMeasureSpec, heightMeasureSpec); }
From source file:com.mfh.litecashier.ui.widget.TopSlidingTabStrip.java
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); if (!allowWidthFull) return;// w w w.j a v a2 s .co m ViewGroup tabsLayout = getTabsLayout(); if (tabsLayout == null || tabsLayout.getMeasuredWidth() >= getMeasuredWidth()) return; if (tabsLayout.getChildCount() <= 0) return; if (tabViews == null) { tabViews = new ArrayList<>(); } else { tabViews.clear(); } for (int w = 0; w < tabsLayout.getChildCount(); w++) { tabViews.add(tabsLayout.getChildAt(w)); } adjustChildWidthWithParent(tabViews, getMeasuredWidth() - tabsLayout.getPaddingLeft() - tabsLayout.getPaddingRight(), widthMeasureSpec, heightMeasureSpec); super.onMeasure(widthMeasureSpec, heightMeasureSpec); }
From source file:me.xiaopan.psts.PagerSlidingTabStrip.java
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { if (allowWidthFull && tabsLayout != null) { View childView;// w w w . ja va 2s .c o m for (int w = 0, size = tabsLayout.getChildCount(); w < size; w++) { childView = tabsLayout.getChildAt(w); ViewGroup.LayoutParams params = childView.getLayoutParams(); params.width = ViewGroup.LayoutParams.WRAP_CONTENT; childView.setLayoutParams(params); } } super.onMeasure(widthMeasureSpec, heightMeasureSpec); if (!allowWidthFull) { return; } ViewGroup tabsLayout = getTabsLayout(); if (tabsLayout == null) { return; } if (tabsLayout.getChildCount() <= 0) { return; } if (tabViews == null) { tabViews = new ArrayList<View>(); } else { tabViews.clear(); } for (int w = 0; w < tabsLayout.getChildCount(); w++) { tabViews.add(tabsLayout.getChildAt(w)); } adjustChildWidthWithParent(tabViews, getMeasuredWidth() - tabsLayout.getPaddingLeft() - tabsLayout.getPaddingRight(), widthMeasureSpec, heightMeasureSpec); super.onMeasure(widthMeasureSpec, heightMeasureSpec); }
From source file:org.dmfs.android.colorpicker.PaletteFragment.java
@Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); /*//www . ja v a 2s . com * TODO: build the layout programmatically to get rid of the resources, so we can distribute this in a single jar */ final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.org_dmfs_colorpickerdialog_palette_grid, container, false); final GridView gridview = (GridView) rootView.findViewById(android.R.id.content); mAdapter = new PaletteGridAdapter(getActivity(), mPalette); gridview.setAdapter(mAdapter); gridview.setOnItemClickListener(this); gridview.setNumColumns(mAdapter.getNumColumns()); /* * Adjust the layout of the gridview to a square. * * Inspired by Bill Lahti, see http://blahti.wordpress.com/2012/07/23/three-variations-of-image-squares/ */ gridview.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @SuppressLint("NewApi") public void onGlobalLayout() { int parentHeight = rootView.getHeight() - rootView.getPaddingTop() - rootView.getPaddingBottom(); int parentWidth = rootView.getWidth() - rootView.getPaddingLeft() - rootView.getPaddingRight(); int gridWidth = Math.min(parentWidth, parentHeight); int columnSpacing; if (android.os.Build.VERSION.SDK_INT >= 16) { columnSpacing = gridview.getHorizontalSpacing() * (mAdapter.getNumColumns() - 1); } else { /* * TODO: getHorizontalSpacing() has been introduced in SDK level 16. We need to find a way to get get the actual spacing. Until then we use * a hard coded value of 8 dip. * * One way would be to use a dimension in the layout. That would allow us to resolve the dimension here. However, that would be one step * away from a library without resource dependencies. Maybe there is an Android dimension resource with a reasonable value? */ DisplayMetrics metrics = inflater.getContext().getResources().getDisplayMetrics(); if (android.os.Build.VERSION.SDK_INT > 10) { columnSpacing = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, metrics) * (mAdapter.getNumColumns() - 1); } else { // Android 2 seems to add spacing around the entire gridview columnSpacing = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, metrics) * mAdapter.getNumColumns(); } } // width of a single column int columnWidth = (gridWidth - columnSpacing) / mAdapter.getNumColumns(); // estimated width of the grid int actualGridWidth = mAdapter.getNumColumns() * columnWidth + columnSpacing; // add padding to center the grid if we don't use the entire space due to rounding errors if (actualGridWidth < gridWidth - 1) { int padding = (gridWidth - actualGridWidth) / 2; if (padding > 0) { gridview.setPadding(padding, padding, padding, padding); } } else { // no padding needed gridview.setPadding(0, 0, 0, 0); } // set the column width gridview.setColumnWidth(columnWidth); android.view.ViewGroup.LayoutParams params = gridview.getLayoutParams(); if (params == null || params.height != gridWidth) // avoid unnecessary updates { LayoutParams lparams = new LinearLayout.LayoutParams(gridWidth, gridWidth); gridview.setLayoutParams(lparams); } } }); return rootView; }
From source file:ti.org.dmfs.android.colorpicker.PaletteFragment.java
@Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); /*//w ww.j a v a 2s . c o m * TODO: build the layout programmatically to get rid of the resources, * so we can distribute this in a single jar */ final ViewGroup rootView = (ViewGroup) inflater .inflate(RHelper.getLayout("org_dmfs_colorpickerdialog_palette_grid"), container, false); final GridView gridview = (GridView) rootView.findViewById(android.R.id.content); mAdapter = new PaletteGridAdapter(getActivity(), mPalette); gridview.setAdapter(mAdapter); gridview.setOnItemClickListener(this); gridview.setNumColumns(mAdapter.getNumColumns()); /* * Adjust the layout of the gridview to a square. * * Inspired by Bill Lahti, see * http://blahti.wordpress.com/2012/07/23/three * -variations-of-image-squares/ */ gridview.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @SuppressLint("NewApi") public void onGlobalLayout() { int parentHeight = rootView.getHeight() - rootView.getPaddingTop() - rootView.getPaddingBottom(); int parentWidth = rootView.getWidth() - rootView.getPaddingLeft() - rootView.getPaddingRight(); int gridWidth = Math.min(parentWidth, parentHeight); int columnSpacing; if (android.os.Build.VERSION.SDK_INT >= 16) { columnSpacing = gridview.getHorizontalSpacing() * (mAdapter.getNumColumns() - 1); } else { /* * TODO: getHorizontalSpacing() has been introduced * in SDK level 16. We need to find a way to get get * the actual spacing. Until then we use a hard * coded value of 8 dip. * * One way would be to use a dimension in the * layout. That would allow us to resolve the * dimension here. However, that would be one step * away from a library without resource * dependencies. Maybe there is an Android dimension * resource with a reasonable value? */ DisplayMetrics metrics = inflater.getContext().getResources().getDisplayMetrics(); if (android.os.Build.VERSION.SDK_INT > 10) { columnSpacing = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, metrics) * (mAdapter.getNumColumns() - 1); } else { // Android 2 seems to add spacing around the // entire gridview columnSpacing = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, metrics) * mAdapter.getNumColumns(); } } // width of a single column int columnWidth = (gridWidth - columnSpacing) / mAdapter.getNumColumns(); // estimated width of the grid int actualGridWidth = mAdapter.getNumColumns() * columnWidth + columnSpacing; // add padding to center the grid if we don't use the // entire space due to rounding errors if (actualGridWidth < gridWidth - 1) { int padding = (gridWidth - actualGridWidth) / 2; if (padding > 0) { gridview.setPadding(padding, padding, padding, padding); } } else { // no padding needed gridview.setPadding(0, 0, 0, 0); } // set the column width gridview.setColumnWidth(columnWidth); android.view.ViewGroup.LayoutParams params = gridview.getLayoutParams(); if (params == null || params.height != gridWidth) // avoid // unnecessary // updates { LayoutParams lparams = new LinearLayout.LayoutParams(gridWidth, gridWidth); gridview.setLayoutParams(lparams); } } }); return rootView; }
From source file:com.jun.fakeoschina.widget.PagerSlidingTabStrip.java
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); if (!allowWidthFull) return;/*from w ww . java2s . com*/ ViewGroup tabsLayout = getTabsLayout(); // tabsLayout.getMeasuredWidth() ? 528 // getMeasuredWidth() pagerSlidingTabStrip xml720 android:layout_width="match_parent" if (tabsLayout == null || tabsLayout.getMeasuredWidth() >= getMeasuredWidth()) return; if (tabsLayout.getChildCount() <= 0) return; if (tabViews == null) { tabViews = new ArrayList<View>(); } else { tabViews.clear(); } for (int w = 0; w < tabsLayout.getChildCount(); w++) { tabViews.add(tabsLayout.getChildAt(w)); } adjustChildWidthWithParent(tabViews, getMeasuredWidth() - tabsLayout.getPaddingLeft() - tabsLayout.getPaddingRight(), widthMeasureSpec, heightMeasureSpec); super.onMeasure(widthMeasureSpec, heightMeasureSpec); }
From source file:com.waz.zclient.pages.main.participants.dialog.ParticipantsDialogFragment.java
private void adjustAccordingToAnchor() { Bundle bundle = getArguments();/*from w ww . j a v a 2s . c o m*/ if (bundle == null || getView() == null) { return; } View view = getView(); ViewGroup viewGroup = (ViewGroup) view.getParent(); Rect rect = bundle.getParcelable(ARG_ANCHOR_RECT); int posX = bundle.getInt(ARG_POS_X); int posY = bundle.getInt(ARG_POS_Y); final int widthSpec = View.MeasureSpec.makeMeasureSpec( viewGroup.getMeasuredWidth() - viewGroup.getPaddingLeft() - viewGroup.getPaddingRight(), View.MeasureSpec.AT_MOST); final int heightSpec = View.MeasureSpec.makeMeasureSpec( viewGroup.getMeasuredHeight() - viewGroup.getPaddingTop() - viewGroup.getPaddingBottom(), View.MeasureSpec.AT_MOST); view.measure(widthSpec, heightSpec); ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) dialogFrameLayout .getLayoutParams(); int rootHeight = dialogFrameLayout.getMeasuredHeight(); int rootWidth = dialogFrameLayout.getMeasuredWidth(); int dialogHeight = rootHeight + layoutParams.bottomMargin + layoutParams.topMargin; int dialogWidth = rootWidth + layoutParams.leftMargin + layoutParams.rightMargin; setDialogPosition(rect, posX, posY, dialogWidth, dialogHeight); }
From source file:com.android.deskclock.stopwatch.StopwatchFragment.java
/** * Show or hide the list of laps.//from w w w.j a v a 2 s . c o m */ private void showOrHideLaps(boolean clearLaps) { final ViewGroup sceneRoot = (ViewGroup) getView(); if (sceneRoot == null) { return; } TransitionManager.beginDelayedTransition(sceneRoot); if (clearLaps) { mLapsAdapter.clearLaps(); } final boolean lapsVisible = mLapsAdapter.getItemCount() > 0; mLapsList.setVisibility(lapsVisible ? VISIBLE : GONE); if (Utils.isPortrait(getActivity())) { // When the lap list is visible, it includes the bottom padding. When it is absent the // appropriate bottom padding must be applied to the container. final Resources res = getResources(); final int bottom = lapsVisible ? 0 : res.getDimensionPixelSize(R.dimen.fab_height); final int top = sceneRoot.getPaddingTop(); final int left = sceneRoot.getPaddingLeft(); final int right = sceneRoot.getPaddingRight(); sceneRoot.setPadding(left, top, right, bottom); } }
From source file:com.wizardsofm.deskclock.stopwatch.StopwatchFragment.java
/** * Show or hide the list of laps./*www . java2 s . co m*/ */ private void showOrHideLaps(boolean clearLaps) { final ViewGroup sceneRoot = (ViewGroup) getView(); if (sceneRoot == null) { return; } TransitionManager.beginDelayedTransition(sceneRoot); if (clearLaps) { mLapsAdapter.clearLaps(); } final boolean lapsVisible = mLapsAdapter.getItemCount() > 0; mLapsList.setVisibility(lapsVisible ? VISIBLE : GONE); if (Utils.isPortrait(getActivity())) { // When the lap list is visible, it includes the bottom padding. When it is absent the // appropriate bottom padding must be applied to the container. final Resources res = getResources(); final int bottom = lapsVisible ? 0 : res.getDimensionPixelSize(com.wizardsofm.deskclock.R.dimen.fab_height); final int top = sceneRoot.getPaddingTop(); final int left = sceneRoot.getPaddingLeft(); final int right = sceneRoot.getPaddingRight(); sceneRoot.setPadding(left, top, right, bottom); } }