翻转文字

偶然看到微信这个面对面发红包,看到上面的文字是反向的,这感觉还挺好,对方也能看的明白
最简单实现:在TextView中添加
android:rotation="180"
即可

翻转文字_第1张图片
Paste_Image.png

源码:

View.java

  case com.android.internal.R.styleable.View_rotation:
                    rotation = a.getFloat(attr, 0);
                    transformSet = true;

    /**
     * Sets the degrees that the view is rotated around the pivot point. Increasing values
     * result in clockwise rotation.
     *
     * @param rotation The degrees of rotation.
     *
     * @see #getRotation()
     * @see #getPivotX()
     * @see #getPivotY()
     * @see #setRotationX(float)
     * @see #setRotationY(float)
     *
     * @attr ref android.R.styleable#View_rotation
     */
    public void setRotation(float rotation) {
        if (rotation != getRotation()) {
            // Double-invalidation is necessary to capture view's old and new areas
            invalidateViewProperty(true, false);
            mRenderNode.setRotation(rotation);
            invalidateViewProperty(false, true);

            invalidateParentIfNeededAndWasQuickRejected();
            notifySubtreeAccessibilityStateChangedIfNeeded();
        }
    }   

RenderNode.java

private static native boolean nSetRotation(long renderNode, float rotation);

用心设计

你可能感兴趣的:(翻转文字)