我正在构建一个与镜像一起使用的应用程序,我的问题是如何创建镜像布局?我想在布局上看到所有 TextView 的按钮..就像我从镜子中观看一样(不可读的文本..)
有什么办法可以做到吗?
镜像文本示例 -
最佳答案
您可以通过在布局上设置 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/