Android以另一种方式将视图移到另一个下方

时间:2015-10-02 08:54:29

标签: android

我有三个视图属于列表视图单元格。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="New Text"
        android:id="@+id/postArea"
        android:layout_below="@+id/date"
        android:layout_alignLeft="@+id/date"
        android:layout_alignStart="@+id/date"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:layout_marginRight="5dp" />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/date"
        android:layout_alignLeft="@+id/date"
        android:layout_alignStart="@+id/date"
        android:id="@+id/shareView">
    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/shareView"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:id="@+id/commentsView">
    </RelativeLayout>
</RelativeLayout>

在某些单元格&#34; shareView&#34;设置为shareView.setVisibility(View.GONE);

在这种情况下,我需要更改commentsView,使其低于postArea

有一种方法可以在我的getView方法中执行此操作。

1 个答案:

答案 0 :(得分:0)

当您将shareView's visibility设置为View.GONE时,您应该更改layout_below的{​​{1}}规则。像这样:

commentsView
相关问题