当前位置: 首页>>代码示例>>Java>>正文


Java ViewCompat.setZ方法代码示例

本文整理汇总了Java中android.support.v4.view.ViewCompat.setZ方法的典型用法代码示例。如果您正苦于以下问题:Java ViewCompat.setZ方法的具体用法?Java ViewCompat.setZ怎么用?Java ViewCompat.setZ使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.view.ViewCompat的用法示例。


在下文中一共展示了ViewCompat.setZ方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawChild

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
    public boolean drawChild(Canvas canvas, View child, long drawingTime) {
        // rotateX
        int centerY = getVerticalSpace() / 2;
        int childCenterY = child.getTop() + child.getHeight() / 2;
        float factor = (centerY - childCenterY) * 1f / centerY;
        float alphaFactor = 1 - 0.7f * Math.abs(factor);
        child.setAlpha(alphaFactor * alphaFactor * alphaFactor);
        float scaleFactor = 1 - 0.3f * Math.abs(factor);
        child.setScaleX(scaleFactor);
        child.setScaleY(scaleFactor);

        float rotateRadius = 2.0f * centerY / (float) Math.PI;
        float rad = (centerY - childCenterY) * 1f / rotateRadius;
        float offsetZ = rotateRadius * (1 - (float) Math.cos(rad));
        float rotateDeg = rad * 180 / (float) Math.PI;
        ViewCompat.setZ(child, -offsetZ);
        child.setRotationX(rotateDeg);

        float offsetY = centerY - childCenterY - rotateRadius * (float) Math.sin(rad) * 1.3f;
        child.setTranslationY(offsetY);

        // resize the text size if text can not be shown completely
        if (child instanceof TextView) {
            String data = ((TextView) child).getText().toString();
            if (((TextView) child).getTextSize() == mTextSize) {
                float finalTextSize = mTextSize;
                float dataStringW = StaticLayout.getDesiredWidth(data, 0, data.length(), ((TextView) child).getPaint());
                if (getHorizontalSpace() > 0 && dataStringW * 1.1f > getHorizontalSpace()) {
                    finalTextSize = getHorizontalSpace() / dataStringW / 1.1f * mTextSize;
                }
                ((TextView) child).setTextSize(TypedValue.COMPLEX_UNIT_PX, finalTextSize);
            }
        }

        return super.drawChild(canvas, child, drawingTime);

//        // parent centerY ,item centerY
//        int centerY = (getHeight() - getPaddingTop() - getPaddingBottom()) / 2;
//        int childCenterY = child.getTop() + child.getHeight() / 2;
//        // alpha
//        float factor = (centerY - childCenterY) * 1f / centerY;
//        float currentFactor = 1 - 0.7f * Math.abs(factor);
//        child.setAlpha(currentFactor * currentFactor * currentFactor);
//
//        // rotate radius
//        float rotateRadius = 2.5f * centerY / (float) Math.PI;
//        // deg
//        float rad = (centerY - childCenterY) * 1f / rotateRadius;
//        float rotateDeg = rad * 180 / (float) Math.PI;
//        // for camera
//        float offsetZ = rotateRadius * (1 - (float) Math.cos(rad));
//        canvas.save();
//        // offset Y for item rotate
//        float offsetY = centerY - childCenterY - rotateRadius * (float) Math.sin(rad);
//        canvas.translate(0, offsetY);
//        mCamera.save();
//        mCamera.translate(0, 0, offsetZ);
//        mCamera.rotateX(rotateDeg);
//        mCamera.getMatrix(mMatrix);
//        mCamera.restore();
//        mMatrix.preTranslate(-child.getWidth() / 2, -childCenterY);
//        mMatrix.postTranslate(child.getWidth() / 2, childCenterY);
//        canvas.concat(mMatrix);
//        super.drawChild(canvas, child, drawingTime);
//        canvas.restore();
//        return true;
    }
 
开发者ID:devilist,项目名称:RecyclerWheelPicker,代码行数:69,代码来源:RecyclerWheelPicker.java

示例2: moveViews

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
/**
 * 移动view
 *
 * @param dy 要移动的距离
 */
private void moveViews(int dy)
{
    if (getDirection() == Direction.FROM_HEADER)
    {
        if (mIsOverLayMode)
        {
            //覆盖模式
            if (ViewCompat.getZ(mHeaderView) <= ViewCompat.getZ(mRefreshView))
            {
                ViewCompat.setZ(mHeaderView, ViewCompat.getZ(mRefreshView) + 1);
            }
        } else
        {
            ViewCompat.offsetTopAndBottom(mRefreshView, dy);
        }
        mHeaderView.onViewPositionChanged(this);
    } else
    {
        if (mIsOverLayMode)
        {
            //覆盖模式
            if (ViewCompat.getZ(mFooterView) <= ViewCompat.getZ(mRefreshView))
            {
                ViewCompat.setZ(mFooterView, ViewCompat.getZ(mRefreshView) + 1);
            }
        } else
        {
            ViewCompat.offsetTopAndBottom(mRefreshView, dy);
        }
        mFooterView.onViewPositionChanged(this);
    }

    if (mOnViewPositionChangedCallback != null)
    {
        mOnViewPositionChangedCallback.onViewPositionChanged(this);
    }
}
 
开发者ID:zj565061763,项目名称:pulltorefresh,代码行数:43,代码来源:FPullToRefreshView.java

示例3: onBindViewHolder

import android.support.v4.view.ViewCompat; //导入方法依赖的package包/类
@Override
public void onBindViewHolder(DialogsHolder holder, int position) {
    DialogModel dialog = dialogs.get(position);
    holder.setPosition(position);
    holder.mLastMessage.setText(dialog.getLastMessage());
    holder.mLastMessageDate.setText(String.valueOf(dialog.getLastMessageTime()));
    if (dialog.getLastMessageUserId() == currentUserId) {
        holder.mMessageAuthor.setText(R.string.me);
    } else {
        String userName = userNames.get(dialog.getLastMessageUserId().longValue());
        if(userName != null)
            holder.mMessageAuthor.setText(userNames.get(dialog.getLastMessageUserId().longValue()));
    }
    holder.mTitle.setText(dialog.getName());
    if (dialog.getUnreadMessagesCount() != null && dialog.getUnreadMessagesCount() != 0) {
        holder.mLastMessageDate.setTextColor(context.getResources().getColor(R.color.chats_item_last_message_date_new));
        holder.mTitle.setTextColor(context.getResources().getColor(R.color.chats_item_name_new));
        holder.mNewMessageIndicator.setVisibility(View.VISIBLE);
        holder.mNewMessageIndicator.setText(String.format("+%d", dialog.getUnreadMessagesCount()));
        ViewCompat.setZ(holder.mNewMessageIndicator, 1000000);
    } else {
        holder.mLastMessageDate.setTextColor(context.getResources().getColor(R.color.chats_item_last_message_date));
        holder.mTitle.setTextColor(context.getResources().getColor(R.color.chats_item_name));
        holder.mNewMessageIndicator.setVisibility(View.GONE);
    }

    holder.swipeLayout.setShowMode(SwipeLayout.ShowMode.LayDown);

    Bitmap photo = dialogPhotos.get(dialog.getDialogId());
    if (photo != null) {
        holder.imageView.setImageBitmap(photo);
    } else {
        holder.imageView.setImageDrawable(context.getResources().getDrawable(R.drawable.user_icon));
    }

    mItemManger.bindView(holder.itemView, position);
}
 
开发者ID:ukevgen,项目名称:BizareChat,代码行数:38,代码来源:DialogsRecyclerViewAdapter.java


注:本文中的android.support.v4.view.ViewCompat.setZ方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。