Java Code Examples for android.view.View.setLeft()

The following are Jave code examples for showing how to use setLeft() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: TableView   File: ColumnHeaderLayoutManager.java   Source Code and License Vote up 7 votes
public void customRequestLayout() {
    int nLeft = getFirstItemLeft();
    int nRight;
    for (int i = findFirstVisibleItemPosition(); i < findLastVisibleItemPosition() + 1; i++) {
        nRight = nLeft + getCacheWidth(i);

        View columnHeader = findViewByPosition(i);
        columnHeader.setLeft(nLeft);
        columnHeader.setRight(nRight);

        layoutDecoratedWithMargins(columnHeader, columnHeader.getLeft(), columnHeader.getTop
                (), columnHeader.getRight(), columnHeader.getBottom());

        nLeft = nRight + 1;
    }
}
 
Example 2
Project: TableView   File: CellLayoutManager.java   Source Code and License Vote up 6 votes
private void fit2(int p_nXPosition, int p_nYPosition, int p_nColumnCachedWidth, View
        p_jColumn) {
    CellRecyclerView child = (CellRecyclerView) findViewByPosition(p_nYPosition);
    if (child != null) {
        ColumnLayoutManager childLayoutManager = (ColumnLayoutManager) child.getLayoutManager();

        int nCellCacheWidth = childLayoutManager.getCacheWidth(p_nXPosition);
        View cell = childLayoutManager.findViewByPosition(p_nXPosition);

        // Control whether the cell needs to be fitted by column header or not.
        if (cell != null) {

            if (nCellCacheWidth != p_nColumnCachedWidth || m_bNeedSetLeft) {

                // This is just for setting width value
                if (nCellCacheWidth != p_nColumnCachedWidth) {
                    nCellCacheWidth = p_nColumnCachedWidth;
                    TableViewUtils.setWidth(cell, nCellCacheWidth);
                    childLayoutManager.setCacheWidth(p_nXPosition, nCellCacheWidth);
                }

                // The left & right values of Column header can be considered. Because this
                // method will be worked
                // after drawing process of main thread.
                if (p_jColumn.getLeft() != cell.getLeft() || p_jColumn.getRight() != cell
                        .getRight()) {
                    // TODO: + 1 is for decoration item. It should be gotten from a generic
                    // method  of layoutManager
                    // Set right & left values
                    cell.setLeft(p_jColumn.getLeft());
                    cell.setRight(p_jColumn.getRight() + 1);
                    childLayoutManager.layoutDecoratedWithMargins(cell, cell.getLeft(), cell
                            .getTop(), cell.getRight(), cell.getBottom());

                    m_bNeedSetLeft = true;
                }
            }
        }
    }
}
 
Example 3
Project: FancyAccordionView   File: AnimatorUtils.java   Source Code and License Vote up 5 votes
@Override
public void set(View view, Integer left) {
    view.setLeft(left);
}
 
Example 4
Project: FancyAccordionView   File: AnimatorUtils.java   Source Code and License Vote up 5 votes
/**
 * Returns an animator that animates the bounds of a single view.
 */
public static Animator getBoundsAnimator(View view, int fromLeft, int fromTop, int fromRight,
                                         int fromBottom, int toLeft, int toTop, int toRight, int toBottom) {
    view.setLeft(fromLeft);
    view.setTop(fromTop);
    view.setRight(fromRight);
    view.setBottom(fromBottom);

    return ObjectAnimator.ofPropertyValuesHolder(view,
            PropertyValuesHolder.ofInt(VIEW_LEFT, toLeft),
            PropertyValuesHolder.ofInt(VIEW_TOP, toTop),
            PropertyValuesHolder.ofInt(VIEW_RIGHT, toRight),
            PropertyValuesHolder.ofInt(VIEW_BOTTOM, toBottom));
}
 
Example 5
Project: TableView   File: CellLayoutManager.java   Source Code and License Vote up 5 votes
private int fit(int p_nXPosition, int p_nYPosition, int p_nLeft, int p_nRight, int
        p_nColumnCachedWidth) {
    CellRecyclerView child = (CellRecyclerView) findViewByPosition(p_nYPosition);

    if (child != null) {
        ColumnLayoutManager childLayoutManager = (ColumnLayoutManager) child.getLayoutManager();

        int nCellCacheWidth = childLayoutManager.getCacheWidth(p_nXPosition);
        View cell = childLayoutManager.findViewByPosition(p_nXPosition);

        // Control whether the cell needs to be fitted by column header or not.
        if (cell != null) {

            if (nCellCacheWidth != p_nColumnCachedWidth || m_bNeedSetLeft) {

                // This is just for setting width value
                if (nCellCacheWidth != p_nColumnCachedWidth) {
                    nCellCacheWidth = p_nColumnCachedWidth;
                    TableViewUtils.setWidth(cell, nCellCacheWidth);
                    childLayoutManager.setCacheWidth(p_nXPosition, nCellCacheWidth);
                }

                // Even if the cached values are same, the left & right value wouldn't change.
                // m_bNeedSetLeftValue & the below lines for it.
                if (p_nLeft != IGNORE_LEFT && cell.getLeft() != p_nLeft) {

                    // Calculate scroll distance
                    int nScrollX = Math.max(cell.getLeft(), p_nLeft) - Math.min(cell.getLeft
                            (), p_nLeft);

                    cell.setLeft(p_nLeft);

                    // It shouldn't be scroll horizontally and the problem is gotten just for
                    // first visible item.
                    if (m_iHorizontalListener.getScrollPositionOffset() > 0 && p_nXPosition
                            == childLayoutManager.findFirstVisibleItemPosition() &&
                            m_iCellRecyclerView.getScrollState() != RecyclerView
                                    .SCROLL_STATE_IDLE) { //


                        m_iHorizontalListener.setScrollPositionOffset(m_iHorizontalListener
                                .getScrollPositionOffset() + nScrollX);
                        childLayoutManager.scrollToPositionWithOffset(m_iHorizontalListener
                                .getScrollPosition(), m_iHorizontalListener
                                .getScrollPositionOffset());
                    }
                }

                if (cell.getWidth() != nCellCacheWidth) {
                    if (p_nLeft != IGNORE_LEFT) {
                        // TODO: + 1 is for decoration item. It should be gotten from a
                        // generic method  of layoutManager
                        // Set right
                        p_nRight = cell.getLeft() + nCellCacheWidth + 1;
                        cell.setRight(p_nRight);

                        childLayoutManager.layoutDecoratedWithMargins(cell, cell.getLeft(),
                                cell.getTop(), cell.getRight(), cell.getBottom());
                    }

                    m_bNeedSetLeft = true;
                }
            }
        }
    } else {
        Log.e(LOG_TAG, " x: " + p_nXPosition + " y: " + p_nYPosition + " child is null. " +
                "Because first visible item position is  " + findFirstVisibleItemPosition());
    }
    return p_nRight;
}