隐形部件仍占用空间

Mok*_*oko 18 android android-layout

所以,我有一个看起来像这样的活动:

http://i.imgur.com/UzexgEA.jpg

如您所见,它有一个按钮,一个列表和一个按钮.

如果满足某些条件,我想隐藏两个按钮只显示列表,但正如您在下一个图像中看到的那样,按钮仍占用空间:

http://i.imgur.com/OyLIfSk.jpg

所以我的问题是,我可以做些什么来扩大列表以占用空间?

这是按钮和列表的布局:

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

    <Button
        android:id="@+id/findSelected"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:onClick="registrarAsistencia"
        android:text="Registrar Asistencia" />

    <ListView
        android:id="@+id/listaAlumnos"
        android:layout_width="fill_parent"
        android:layout_height="376dp"
        android:layout_weight="2.29" />

    <Button
        android:id="@+id/btnChecarBoxes"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:onClick="seleccionarTodosNinguno"
        android:text="Seleccionar / Deseleccionar todo" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

这里是列表内容的布局:

<?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="match_parent"
    android:orientation="vertical" >

  <LinearLayout
      android:layout_width="wrap_content"
      android:layout_height="match_parent"
      android:layout_alignParentLeft="true"
      android:layout_alignParentTop="true"
      android:orientation="vertical" >

      <TextView
          android:id="@+id/rowTextView"
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          android:padding="10dp"
          android:textSize="16sp" 
          android:textStyle="bold"/>

      <TextView
          android:id="@+id/rowTextView2"
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          android:padding="10dp"
          android:textSize="16sp" 
          android:textStyle="italic"/>

  </LinearLayout>

  <CheckBox
      android:id="@+id/CheckBox01"
      android:layout_width="wrap_content"
      android:layout_height="match_parent"
      android:layout_alignParentRight="true"
      android:layout_centerVertical="true"
      android:focusable="false"
      android:padding="10dp" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

Com*_*are 69

不要制作按钮View.INVISIBLE.制作按钮View.GONE.有三种可见性状态:

  • 可见(正常)
  • 不可见(未绘制像素,但仍占用空间)
  • 消失了(不包括在渲染中)