Example usage for android.view View getPaddingLeft

List of usage examples for android.view View getPaddingLeft

Introduction

In this page you can find the example usage for android.view View getPaddingLeft.

Prototype

public int getPaddingLeft() 

Source Link

Document

Returns the left padding of this view.

Usage

From source file:com.waz.zclient.pages.main.conversation.views.row.message.views.TextMessageWithTimestamp.java

private void expandTimestamp() {
    if (messageViewContainer.getShownTimestampView() != null
            && messageViewContainer.getShownTimestampView() != this) {
        messageViewContainer.getShownTimestampView().collapseTimestamp();
    }//from w w  w .  j  av  a 2 s .  c o  m
    messageViewContainer.getTimestampShownSet().add(messageId);
    messageViewContainer.setShownTimestampView(this);
    timestampTextView.setVisibility(VISIBLE);

    View parent = (View) timestampTextView.getParent();
    final int widthSpec = MeasureSpec.makeMeasureSpec(
            parent.getMeasuredWidth() - parent.getPaddingLeft() - parent.getPaddingRight(),
            MeasureSpec.AT_MOST);
    final int heightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
    timestampTextView.measure(widthSpec, heightSpec);
    ValueAnimator animator = createHeightAnimator(timestampTextView, 0, timestampTextView.getMeasuredHeight());
    animator.start();
}

From source file:com.qs.qswlw.view.Mypager.UltraViewPagerView.java

protected void onMeasurePage(int widthMeasureSpec, int heightMeasureSpec) {
    Log.d("TEST", "onMeasurePage" + getCurrentItem());
    View child = pagerAdapter.getViewAtPosition(getCurrentItem());
    if (child == null) {
        child = getChildAt(0);/*w  w w  .j av  a  2s  . c  o m*/
    }
    if (child == null) {
        return;
    }
    for (int i = 0; i < getChildCount(); 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 = MeasureSpec.getSize(childHeightSpec) - getPaddingTop() - getPaddingBottom();

    if (!needsMeasurePage || childWidth == 0 && childHeight == 0) {
        return;
    }

    if (!Double.isNaN(itemRatio)) {
        int itemHeight = (int) (childWidth / itemRatio);
        for (int i = 0, childCount = getChildCount(); i < childCount; i++) {
            View view = getChildAt(i);
            view.measure(MeasureSpec.makeMeasureSpec(childWidth, MeasureSpec.EXACTLY),
                    MeasureSpec.makeMeasureSpec(itemHeight, MeasureSpec.EXACTLY));
        }
    } else {
        for (int i = 0, childCount = getChildCount(); 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);
            }
        }
    }

    final boolean isHorizontalScroll = scrollMode == UltraViewPager.ScrollMode.HORIZONTAL;

    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, childCount = getChildCount(); i < childCount; i++) {
            View view = getChildAt(i);
            view.measure(MeasureSpec.makeMeasureSpec(childWidth, MeasureSpec.EXACTLY), heightMeasureSpec);
        }
    } else {
        if (autoMeasureHeight) {
            if (isHorizontalScroll) {
                constrainLength = MeasureSpec.makeMeasureSpec(childHeight, MeasureSpec.EXACTLY);
                setMeasuredDimension(getMeasuredWidth(), childHeight);
            } else {
                constrainLength = MeasureSpec.makeMeasureSpec(childWidth, MeasureSpec.EXACTLY);
                setMeasuredDimension(childWidth, getMeasuredHeight());
            }

            needsMeasurePage = childHeight == itemMarginTop + itemMarginBottom;
        }
    }

    if (!pagerAdapter.isEnableMultiScr()) {
        return;
    }

    int pageLength = isHorizontalScroll ? getMeasuredWidth() : getMeasuredHeight();

    final int childLength = isHorizontalScroll ? child.getMeasuredWidth() : child.getMeasuredHeight();

    // Check that the measurement was successful
    if (childLength > 0) {
        needsMeasurePage = false;
        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.android.contacts.list.MultiSelectContactsListFragment.java

private void setListViewPaddingTop(View listView, int paddingTop) {
    listView.setPadding(listView.getPaddingLeft(), paddingTop, listView.getPaddingRight(),
            listView.getPaddingBottom());
}

From source file:com.xycode.xylibrary.uiKit.recyclerview.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(headerList.get(position), child.getPaddingLeft() + mTextStartMargin,
            rectBottom - (mTitleHeight - mTextHeight) / 2 - mTextBaselineOffset, mTextPaint);
}

From source file:com.github.omadahealth.slidepager.lib.views.SlideChartView.java

/**
 * Set the padding on the {@link View} based on {@link #mOutlineSize}
 *//*from   w w w.ja  v  a2 s. co m*/
private void setPaddingForOutlineSize(View view) {
    view.setPadding(view.getPaddingLeft(), (int) mOutlineSize, view.getPaddingRight(), (int) mOutlineSize);
}

From source file:org.mifos.androidclient.main.DepositDueDetailsActivity.java

private void updateContent(SavingsAccountDepositDue details) {
    mDetails = details;/*w w w.  j  av a 2  s . c om*/
    TextView cell;
    Double nextDeposit, pastDepositAmount, pastDepositsSum = 0.0;

    cell = (TextView) findViewById(R.id.depositDueDetails_nextDeposit);
    nextDeposit = details.getNextDueDetail().getDueAmount();
    cell.setText(nextDeposit.toString());

    if (ValueUtils.hasElements(details.getPreviousDueDetails())) {
        TableLayout table = (TableLayout) findViewById(R.id.depositDueDetails_table);
        View view = findViewById(R.id.depositDueDetails_rowInsertPoint);
        int index = table.indexOfChild(view) + 1;
        view = findViewById(R.id.depositDueDetails_subTotal_label);
        TableLayoutHelper helper = new TableLayoutHelper(this,
                TableLayoutHelper.DEFAULT_TABLE_ROW_SEPARATOR_HEIGHT, view.getPaddingLeft(),
                view.getPaddingRight());

        for (DueOnDate pastDeposit : details.getPreviousDueDetails()) {
            if (pastDeposit.getDueDate().before(details.getNextDueDetail().getDueDate())) {
                TableRow row = helper.createTableRow();
                cell = helper.createTableCell(DateUtils.format(pastDeposit.getDueDate()), 1);
                row.addView(cell);
                pastDepositAmount = pastDeposit.getDueAmount();
                cell = helper.createTableCell(pastDepositAmount.toString(), 2);
                row.addView(cell);
                table.addView(row, index);
                index++;
                table.addView(helper.createRowSeparator(), index);
                index++;
                pastDepositsSum += pastDepositAmount;
            }
        }
    }

    cell = (TextView) findViewById(R.id.depositDueDetails_subTotal);
    cell.setText(pastDepositsSum.toString());
    cell = (TextView) findViewById(R.id.depositDueDetails_totalAmountDue_label);
    cell.setText(cell.getText() + DateUtils.format(details.getNextDueDetail().getDueDate()));
    cell = (TextView) findViewById(R.id.depositDueDetails_totalAmountDue);
    cell.setText(Double.toString(pastDepositsSum + nextDeposit));
}

From source file:com.gruporaido.tasker_library.util.Helper.java

/**
 * Adds an extra bottom padding in case there is a Software Navigation Bar
 *
 * @param view//from   www.jav a2 s  .  co m
 */
public void addBottomPaddingforSoftNavbar(View view) {
    if (!ViewConfiguration.get(mContext).hasPermanentMenuKey()) {
        view.setPadding(view.getPaddingLeft(), view.getPaddingTop(), view.getPaddingRight(),
                view.getPaddingBottom() + navigationBarSize());
    }
}

From source file:com.github.crvv.wubinput.wubi.dictionary.suggestions.SuggestionStripView.java

boolean showMoreSuggestions() {
    final Keyboard parentKeyboard = mMainKeyboardView.getKeyboard();
    if (parentKeyboard == null) {
        return false;
    }//www .j a v a 2  s .  c  o  m
    final SuggestionStripLayoutHelper layoutHelper = mLayoutHelper;
    if (mSuggestedWords.size() <= mStartIndexOfMoreSuggestions) {
        return false;
    }
    // Dismiss another {@link MoreKeysPanel} that may be being showed, for example
    // {@link MoreKeysKeyboardView}.
    mMainKeyboardView.onDismissMoreKeysPanel();
    // Dismiss all key previews and sliding key input preview that may be being showed.
    mMainKeyboardView.dismissAllKeyPreviews();
    mMainKeyboardView.dismissSlidingKeyInputPreview();
    final int stripWidth = getWidth();
    final View container = mMoreSuggestionsContainer;
    final int maxWidth = stripWidth - container.getPaddingLeft() - container.getPaddingRight();
    final MoreSuggestions.Builder builder = mMoreSuggestionsBuilder;
    builder.layout(mSuggestedWords, mStartIndexOfMoreSuggestions, maxWidth,
            (int) (maxWidth * layoutHelper.mMinMoreSuggestionsWidth), layoutHelper.getMaxMoreSuggestionsRow(),
            parentKeyboard);
    mMoreSuggestionsView.setKeyboard(builder.build());
    container.measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);

    final MoreKeysPanel moreKeysPanel = mMoreSuggestionsView;
    final int pointX = stripWidth / 2;
    final int pointY = -layoutHelper.mMoreSuggestionsBottomGap;
    moreKeysPanel.showMoreKeysPanel(this, mMoreSuggestionsController, pointX, pointY, mMoreSuggestionsListener);
    mOriginX = mLastX;
    mOriginY = mLastY;
    for (int i = 0; i < mStartIndexOfMoreSuggestions; i++) {
        mWordViews.get(i).setPressed(false);
    }
    return true;
}

From source file:com.chess.genesis.view.SwipeTabs.java

/**
 * Calculate the position of the tabs.// w  w  w  . j av a  2 s. c  o m
 *
 * @param position
 *            the position of the fronted tab
 * @param tabPositions
 *            the array in which to store the result
 */
private void calculateTabPosition(final int position, final int[] tabPositions) {
    if (mAdapter == null)
        return;

    final int count = mAdapter.getCount();

    if (position >= 0 && position < count) {
        final int width = getMeasuredWidth();

        final View centerTab = getChildAt(position);
        tabPositions[position] = width / 2 - centerTab.getMeasuredWidth() / 2;
        for (int i = position - 1; i >= 0; i--) {
            final View tab = getChildAt(i);
            if (i == position - 1)
                tabPositions[i] = -tab.getPaddingLeft();
            else
                tabPositions[i] = -tab.getMeasuredWidth() - width;

            tabPositions[i] = Math.min(tabPositions[i], tabPositions[i + 1] - tab.getMeasuredWidth());
        }
        for (int i = position + 1; i < count; i++) {
            final View tab = getChildAt(i);
            if (i == position + 1)
                tabPositions[i] = width - tab.getMeasuredWidth() + tab.getPaddingRight();
            else
                tabPositions[i] = width * 2;

            final View prevTab = getChildAt(i - 1);
            tabPositions[i] = Math.max(tabPositions[i], tabPositions[i - 1] + prevTab.getMeasuredWidth());
        }
    } else {
        for (int i = 0; i < tabPositions.length; i++)
            tabPositions[i] = -1;
    }
}

From source file:com.astuetz.viewpager.extensions.SwipeyTabsView.java

private int left(int position) {
    View tab = getChildAt(position);
    return 0 - tab.getPaddingLeft();
}