根据另一个已存在的视图,是否可以使用RelativeLayout居中水平或垂直对齐XML中的视图。RelativeLayout:align相对于其他视图居中水平或垂直
例如:可以说有这样的事情:
第二个文本视图应显示为中心的第一个文本视图下方:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginLeft="72dp"
android:text="dynamic text" />
<TextView
android:id="@+id/second"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/textView"
android:layout_marginLeft="43dp" <!-- Is there a rule to center it? -->
android:text="centered below text 1" />
</RelativeLayout>
是有可能实现类似于XML中的东西?有没有规则,我错过了?我不想计算位置编程
不,我不想将它居于父母 – sockeqwe 2013-05-12 19:00:42
你需要它 – Noundla 2013-05-12 19:01:18
我修改了答案。检查一次。 – Noundla 2013-05-12 19:04:59