android - 创建镜像布局

标签 android android-layout mirror

我正在构建一个与镜像一起使用的应用程序,我的问题是如何创建镜像布局?我想在布局上看到所有 TextView 的按钮..就像我从镜子中观看一样(不可读的文本..)

有什么办法可以做到吗?

镜像文本示例 - mirror..

最佳答案

您可以通过在布局上设置 setScaleY(-1f) 来实现这一点。

因此您的主布局可能如下所示(模仿您的示例图像):

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <TextView
        android:id="@+id/source_text_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@android:color/white"
        android:text="LOREM"
        android:textColor="#0084E2"/>

    <TextView
        android:id="@+id/copy_text_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#0084E2"
        android:scaleY="-1"
        android:text="LOREM"
        android:textColor="@android:color/white"/>

</LinearLayout>

第二个View(或ViewGroup)必须是第一个 View 的精确副本。您可以创建一个自定义 ViewGroup,它会自动创建 View 的副本,并将其 scaleY 设置为 -1f .

关于android - 创建镜像布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33007916/

相关文章:

java - 如何在 Android 上查询 ContentProvider 的值不为 null?

java - AsyncTask 中的 ProgressDialog 未关闭

android - 按钮出现在 android API 19 中,但不是 API 17

git - 使用子模块镜像 git 存储库

javascript - 减少反斜杠数量的 evaluateJavascript 函数

android - 回收空间 ItemDecoration 在滚动过程中不断增加

android:创建在滚动时折叠的布局

android - createBitmap --- java.lang.IllegalArgumentException : x must be < bitmap. 宽度()

json - 我可以使用镜像设置 Swift 对象属性的值吗?

Git 本地镜像和仓库