0
我有一个相对布局(RV1),其中顶部是列表视图。在这之下,我有另一个相对视图(R2),它包含一个图像和按钮。 最后在R2下面,在R1的底部有一个编辑框和一个按钮(B1)。当图层可见性发生变化时刷新图层
最初,R2被设置为可见性(不存在),因此列表仅位于编辑框的顶部。但是,当我按下按钮B1时,我希望R2可见并且列表现在可以在R2之上移动。
在xml设置中,列表设置为高于R2:android:layout_above =“@ id/R2Layout” 但是由于R2最初设置为不存在,列表位于编辑框的顶部。没关系。
我的问题是,一旦按钮B1被按下,R2就会变得可见,但是列表不会让R2产生空间并移动到R2上方。 R2和列表相互重叠。
我试图通过做view.invalidate()使整个视图刷新自己,但它没有工作。
我该如何解决这个问题?
下面是xml代码。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/r1"
android:layout_width="match_parent"
android:layout_height="fill_parent" >
<EditText
android:id="@+id/et"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:layout_toLeftOf="@+id/b1"
android:padding="5dp"
android:paddingTop="10dp" >
</EditText>
<RelativeLayout
android:id="@+id/r2"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_margin="5dp"
android:layout_height="wrap_content"
android:layout_above="@+id/et"
android:layout_alignParentLeft="true" >
<ImageView
android:id="@+id/iv"
android:visibility="gone"
android:layout_width="80dp"
android:layout_height="80dp" />
<Button
android:id="@+id/b2"
android:visibility="gone"
android:layout_marginLeft="5dp"
android:layout_toRightOf="@+id/iv"
android:layout_alignTop="@+id/iv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="button" />
</RelativeLayout>
<FrameLayout
android:id="@+id/frameLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/r2"
android:layout_marginBottom="10dp" >
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:dividerHeight="2.0sp"
android:fastScrollEnabled="true"
android:smoothScrollbar="true"
android:stackFromBottom="true" />
<!-- Here is the view to show if the list is empty -->
<LinearLayout
android:id="@+id/empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<!-- If the list is empty because there are no files... -->
<TextView
android:id="@+id/empty_text"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:visibility="invisible"
android:text="List empty"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</FrameLayout>
<Button
android:id="@+id/b1"
android:layout_width="50dip"
android:layout_height="50dip"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="5dp" />
</RelativeLayout>
你应该张贴的XML进行你的布局。 – dymmeh 2013-04-30 03:54:21
在这种情况下,您的布局通常存在问题。如果其他人可以看到他们可以帮助你的布局。 – HalR 2013-04-30 03:55:39
我已经建议用xml更新。谢谢 – fawx 2013-04-30 04:17:16