List of usage examples for android.view View getPaddingLeft
public int getPaddingLeft()
From source file:com.android.mail.browse.ConversationItemViewCoordinates.java
@SuppressLint("NewApi") private static void setFramePadding(Context context, ViewGroup view, boolean useFullPadding) { final Resources res = context.getResources(); final int padding = res.getDimensionPixelSize( useFullPadding ? R.dimen.conv_list_card_border_padding : R.dimen.conv_list_no_border_padding); final View frame = view.findViewById(R.id.conversation_item_frame); if (Utils.isRunningJBMR1OrLater()) { // start, top, end, bottom frame.setPaddingRelative(frame.getPaddingStart(), padding, frame.getPaddingEnd(), padding); } else {/*from ww w. j a v a 2s . c o m*/ frame.setPadding(frame.getPaddingLeft(), padding, frame.getPaddingRight(), padding); } }
From source file:android.tumb.com.tumb.Misc.DividerItemDecoration.java
@Override public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { view.setPadding(view.getPaddingLeft(), view.getPaddingTop(), view.getPaddingRight(), 0); }
From source file:com.tomeokin.lspush.biz.collect.ImageDialogFragment.java
private float optimumRadio(View content, View container, float width, float height) { final int maxWidth = content.getWidth() - container.getPaddingLeft() - container.getPaddingRight() - 50; final int maxHeight = content.getHeight() / 2 - container.getPaddingTop() - container.getPaddingBottom(); //Timber.i("maxWidth: %d, maxHeight: %d", maxWidth, maxHeight); return ImageUtils.optimumRadio(maxWidth, maxHeight, width, height); }
From source file:pl.motyczko.scrollheadersample.ColorFragment.java
/** * {@inheritDoc}//from w w w. j a va 2 s. c om */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final int color = getArguments().getInt("color"); View v = inflater.inflate(R.layout.fragment_color, container, false); v.setBackgroundColor(color); int paddingTop = getActivity().findViewById(R.id.view_pager_header).getMeasuredHeight(); v.setPadding(v.getPaddingLeft(), paddingTop, v.getPaddingRight(), v.getPaddingBottom()); return v; }
From source file:com.dk.animation.effect.out.HingeOut.java
@Override public void startAnimation(final ViewHolder holder, long duration, final BaseItemAnimator animator) { ViewCompat.animate(holder.itemView).cancel(); AnimatorSet set = new AnimatorSet(); View target = holder.itemView; int abs = Math.random() > 0.5 ? -1 : 1; float x, y;/* ww w. j a va2 s . c om*/ if (abs > 0) { x = target.getPaddingLeft(); y = target.getPaddingTop(); } else { x = target.getWidth(); y = target.getPaddingTop(); } set.setDuration(animator.getRemoveDuration()); set.addListener(new AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationRepeat(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { animator.dispatchAddFinished(holder); animator.mAddAnimations.remove(holder); animator.dispatchFinishedWhenDone(); } @Override public void onAnimationCancel(Animator animation) { } }); set.playTogether( ObjectAnimator.ofFloat(target, "rotation", 0, abs * 80, abs * 60, abs * 80, abs * 60, abs * 60), ObjectAnimator.ofFloat(target, "translationY", 0, 0, 0, 0, 0, 700), ObjectAnimator.ofFloat(target, "alpha", 1, 1, 1, 1, 1, 0), ObjectAnimator.ofFloat(target, "pivotX", x, x, x, x, x, x), ObjectAnimator.ofFloat(target, "pivotY", y, y, y, y, y, y)); set.setStartDelay(mDelay * mDelayCount); set.setDuration(animator.getAddDuration()); set.start(); animator.mAddAnimations.add(holder); }
From source file:pl.kodujdlapolski.na4lapy.ui.drawer.DrawerActivityHandler.java
private void setDrawerHeader() { View headerView = navigationView.getHeaderView(0); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { headerView.setPadding(headerView.getPaddingLeft(), (int) (headerView.getPaddingTop() + activity.getResources().getDimension(R.dimen.status_bar)), headerView.getPaddingRight(), headerView.getPaddingBottom()); }// w w w .j a v a 2 s. co m }
From source file:com.tmall.wireless.tangram.view.BannerViewPager.java
protected void onMeasurePage(int widthMeasureSpec, int heightMeasureSpec) { View child = pagerAdapter.getViewAtPosition(getCurrentItem()); if (child == null) { child = getChildAt(0);//from w ww. j av a2s. c o m } if (child == null) { return; } int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { View view = getChildAt(i); if ((view.getPaddingLeft() != itemMarginLeft || view.getPaddingTop() != itemMarginTop || view.getPaddingRight() != itemMarginRight || view.getPaddingBottom() != itemMarginBottom)) { view.setPadding(itemMarginLeft, itemMarginTop, itemMarginRight, itemMarginBottom); } } ViewGroup.LayoutParams lp = child.getLayoutParams(); final int childWidthSpec = getChildMeasureSpec(widthMeasureSpec, 0, lp.width); final int childHeightSpec = getChildMeasureSpec(heightMeasureSpec, 0, lp.height); int childWidth = (int) ((MeasureSpec.getSize(childWidthSpec) - getPaddingLeft() - getPaddingRight()) * pagerAdapter.getPageWidth(getCurrentItem())); int childHeight = 0; if (!Double.isNaN(itemRatio)) { int itemHeight = (int) (childWidth / itemRatio); for (int i = 0; i < childCount; i++) { View view = getChildAt(i); view.measure(MeasureSpec.makeMeasureSpec(childWidth, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(itemHeight, MeasureSpec.EXACTLY)); } } else { for (int i = 0; i < childCount; i++) { View view = getChildAt(i); if (pagerAdapter.getPageWidth(getCurrentItem()) != 1) { view.measure(MeasureSpec.makeMeasureSpec(childWidth, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); } else { view.measure(childWidthSpec, childHeightSpec); } } } childWidth = itemMarginLeft + child.getMeasuredWidth() + itemMarginRight; childHeight = itemMarginTop + child.getMeasuredHeight() + itemMarginBottom; if (!Float.isNaN(ratio)) { heightMeasureSpec = MeasureSpec.makeMeasureSpec((int) (getMeasuredWidth() / ratio), MeasureSpec.EXACTLY); setMeasuredDimension(widthMeasureSpec, heightMeasureSpec); for (int i = 0; i < childCount; i++) { View view = getChildAt(i); view.measure(MeasureSpec.makeMeasureSpec(childWidth, MeasureSpec.EXACTLY), heightMeasureSpec); } } else { if (autoMeasureHeight) { constrainLength = MeasureSpec.makeMeasureSpec(childHeight, MeasureSpec.EXACTLY); setMeasuredDimension(getMeasuredWidth(), childHeight); } } if (!pagerAdapter.isEnableMultiScr()) { return; } int pageLength = getMeasuredWidth(); final int childLength = child.getMeasuredWidth(); // Check that the measurement was successful if (childLength > 0) { int difference = pageLength - childLength; if (getPageMargin() == 0) { setPageMargin(-difference); } int offscreen = (int) Math.ceil((float) pageLength / (float) childLength) + 1; setOffscreenPageLimit(offscreen); requestLayout(); } }
From source file:com.tmall.wireless.tangram3.view.BannerViewPager.java
protected void onMeasurePage(int widthMeasureSpec, int heightMeasureSpec) { if (pagerAdapter == null) { return;//from www .j av a2 s.c o m } View child = pagerAdapter.getViewAtPosition(getCurrentItem()); if (child == null) { child = getChildAt(0); } if (child == null) { return; } int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { View view = getChildAt(i); if ((view.getPaddingLeft() != itemMarginLeft || view.getPaddingTop() != itemMarginTop || view.getPaddingRight() != itemMarginRight || view.getPaddingBottom() != itemMarginBottom)) { view.setPadding(itemMarginLeft, itemMarginTop, itemMarginRight, itemMarginBottom); } } ViewGroup.LayoutParams lp = child.getLayoutParams(); final int childWidthSpec = getChildMeasureSpec(widthMeasureSpec, 0, lp.width); final int childHeightSpec = getChildMeasureSpec(heightMeasureSpec, 0, lp.height); int childWidth = (int) ((MeasureSpec.getSize(childWidthSpec) - getPaddingLeft() - getPaddingRight()) * pagerAdapter.getPageWidth(getCurrentItem())); int childHeight = 0; if (!Double.isNaN(itemRatio) || itemRatio != 0) { int itemHeight = (int) (childWidth / itemRatio); for (int i = 0; i < childCount; i++) { View view = getChildAt(i); view.measure(MeasureSpec.makeMeasureSpec(childWidth, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(itemHeight, MeasureSpec.EXACTLY)); } } else { for (int i = 0; i < childCount; i++) { View view = getChildAt(i); if (pagerAdapter.getPageWidth(getCurrentItem()) != 1) { view.measure(MeasureSpec.makeMeasureSpec(childWidth, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)); } else { view.measure(childWidthSpec, childHeightSpec); } } } childWidth = itemMarginLeft + child.getMeasuredWidth() + itemMarginRight; childHeight = itemMarginTop + child.getMeasuredHeight() + itemMarginBottom; if (!Float.isNaN(ratio)) { heightMeasureSpec = MeasureSpec.makeMeasureSpec((int) (getMeasuredWidth() / ratio), MeasureSpec.EXACTLY); setMeasuredDimension(widthMeasureSpec, heightMeasureSpec); for (int i = 0; i < childCount; i++) { View view = getChildAt(i); view.measure(MeasureSpec.makeMeasureSpec(childWidth, MeasureSpec.EXACTLY), heightMeasureSpec); } } else { if (autoMeasureHeight) { constrainLength = MeasureSpec.makeMeasureSpec(childHeight, MeasureSpec.EXACTLY); setMeasuredDimension(getMeasuredWidth(), childHeight); } } if (!pagerAdapter.isEnableMultiScr()) { return; } int pageLength = getMeasuredWidth(); final int childLength = child.getMeasuredWidth(); // Check that the measurement was successful if (childLength > 0) { int difference = pageLength - childLength; if (getPageMargin() == 0) { setPageMargin(-difference); } int offscreen = (int) Math.ceil((float) pageLength / (float) childLength) + 1; setOffscreenPageLimit(offscreen); requestLayout(); } }
From source file:com.hgdendi.contactslist.common.FloatingBarItemDecoration.java
private void drawTitleArea(Canvas c, int left, int right, View child, RecyclerView.LayoutParams params, int position) { final int rectBottom = child.getTop() - params.topMargin; c.drawRect(left, rectBottom - mTitleHeight, right, rectBottom, mBackgroundPaint); c.drawText(mList.get(position), child.getPaddingLeft() + mTextStartMargin, rectBottom - (mTitleHeight - mTextHeight) / 2 - mTextBaselineOffset, mTextPaint); }
From source file:com.dycody.android.idealnote.NavigationDrawerFragment.java
public void init() { Log.d(Constants.TAG, "Started navigation drawer initialization"); mDrawerLayout = (DrawerLayout) mActivity.findViewById(R.id.drawer_layout); mDrawerLayout.setFocusableInTouchMode(false); // Setting specific bottom margin for Kitkat with translucent nav bar if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { View leftDrawer = getView().findViewById(R.id.left_drawer); int leftDrawerBottomPadding = Display.getNavigationBarHeightKitkat(getActivity()); leftDrawer.setPadding(leftDrawer.getPaddingLeft(), leftDrawer.getPaddingTop(), leftDrawer.getPaddingRight(), leftDrawerBottomPadding); }//from w w w. j a v a2 s . co m // ActionBarDrawerToggle ties together the the proper interactions // between the sliding drawer and the action bar app icon mDrawerToggle = new ActionBarDrawerToggle(mActivity, mDrawerLayout, getMainActivity().getToolbar(), R.string.drawer_open, R.string.drawer_close) { public void onDrawerClosed(View view) { mActivity.supportInvalidateOptionsMenu(); } public void onDrawerOpened(View drawerView) { mActivity.commitPending(); mActivity.finishActionMode(); } }; if (isDoublePanelActive()) { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN); } // Styling options mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); mDrawerLayout.setDrawerListener(mDrawerToggle); mDrawerToggle.setDrawerIndicatorEnabled(true); Log.d(Constants.TAG, "Finished navigation drawer initialization"); }