设置视图可见性消失保留其他视图

spe*_*123 1 java xml android

我有一些看起来像这样的 xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    <TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="text"
    android:id="@+id/Text"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:textSize="34sp"/>
   <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Call"
    android:id="@+id/callText"
    android:layout_below="@+id/Text"
    android:layout_alignLeft="@+id/Text"
    android:layout_alignStart="@+id/Text"
    />

 />
Run Code Online (Sandbox Code Playgroud)

现在我想将带有 id 的 TextView 设置Text为 GONE,但是当我这样做时,带有 id 的 TextViewcallText也会消失,我想要的是设置Text为 GONE,然后向上callText移动并保持可见?

我怎么能这样做呢?

谢谢

ci_*_*ci_ 5

如果指定的锚点丢失,您可以使用android:layout_alignWithParentIfMissing="true"父级作为锚点:

http://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams.html#attr_android:layout_alignWithParentIfMissing

如果设置为true,当layout_toLeftOf、layout_toRightOf等找不到锚点时,将使用父级作为锚点。