水平镜像Android XML布局
我有一个水平镜像的布局,即在屏幕左侧左对齐的视图和在屏幕右侧右对齐的视图。 对左视图进行更改,然后将更改复制到右视图,同时将所有方向从左向右切换,这有点繁琐。 例如,此文本视图:水平镜像Android XML布局,android,xml,Android,Xml,我有一个水平镜像的布局,即在屏幕左侧左对齐的视图和在屏幕右侧右对齐的视图。 对左视图进行更改,然后将更改复制到右视图,同时将所有方向从左向右切换,这有点繁琐。 例如,此文本视图: <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="hello" android:gravity="left" android:la
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello"
android:gravity="left"
android:layout_toLeftOf="@+id/other_view"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello"
android:gravity="right"
android:layout_toRightOf="@+id/other_view"/>
必须使用此textView在另一侧进行复制:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello"
android:gravity="left"
android:layout_toLeftOf="@+id/other_view"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello"
android:gravity="right"
android:layout_toRightOf="@+id/other_view"/>
这是可以管理的,但我很好奇是否有比每次都更改复制粘贴更好的解决方案。也许可以通过编程方式完成某些事情,但这样做会消除在XML中设计时看到更改的好处