Android TextView进行轻微移动

Android TextView进行轻微移动,android,textview,Android,Textview,我有两个文本视图。第一个是居中的,第二个与父对象的最右边缘对齐 当我在第二个文本视图中更新文本时,它会使第一个文本视图略微向左移动,然后回到其在中心的原始位置 我不知道发生了什么事 这是我的.xml文件的相关部分 <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <TextView android:id="

我有两个文本视图。第一个是居中的,第二个与父对象的最右边缘对齐

当我在
第二个文本视图中更新文本时,它会使
第一个文本视图略微向左移动,然后回到其在中心的原始位置

我不知道发生了什么事

这是我的.xml文件的相关部分

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <TextView
        android:id="@+id/MC_title"
        android:layout_width="wrap_content"
        android:layout_height="160dp"
        android:layout_centerInParent="true"/>

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:layout_marginRight="16dp"
        android:layout_marginTop="22dp" />
 </RelativeLayout>

这是因为外部相对物的大小取决于其子对象的大小。
由于您的第一个文本视图中有
android:layout\u centerInParent=“true”
,因此当相对页面的大小改变时,其中心也会改变。

我认为可能android:layout\u centerInParent=“true”而不是android:layout\u centerInParent=“true”可以解决您的问题。

但是宽度从未改变,它被设置为匹配父视图是的,但是布局过程会发生,并且在布局过程中,视图会被多次测量。尝试将RelativeLayout的大小设置为固定值。为了检查这是否是问题所在,请用xml的所有内容更新它好吗?至少在第一个文本视图中,似乎缺少了一些东西。谢谢