翻转文字

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

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);

用心设计

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,251评论 25 708
  • ¥开启¥ 【iAPP实现进入界面执行逐一显】 〖2017-08-25 15:22:14〗 《//首先开一个线程,因...
    小菜c阅读 6,511评论 0 17
  • 夏天到了,你是在20度的海边城市里嘚瑟,还是在40度的烈日下“苟延残喘”。反正作为女生,天天在40度的高温下,我是...
    肖真阅读 893评论 0 0
  • 桃花一枝横庭中,朵朵粉嫩若腮红。 此生情深归何处,天涯浪尽无人同。
    商南萧阅读 209评论 6 0
  • 今天写简书有些晚了,要不是和大家的约定。今天这片简书肯定不写了。今天感觉过的特别快,不知不觉已经到这个点了,好久没...
    杨荣鹏阅读 310评论 2 1