我有一个视图,实际上是一个按钮。这里是它的XML布局(add_new.xml)
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
android:id="@+id/buttonNew"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/bText"
android:onClick="addNew"/>
当我把它的可见性设置为GONE这样
v = getActivity().getLayoutInflater().inflate(R.layout.add_new, null);
v.setVisibility(View.GONE);
它消失但仍占据空间。喜欢这个:
此按钮是ListView中的一个标题,它由此xml定义:
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/porno" >
android:id="@+id/icon"
android:layout_width="30dp"
android:layout_height="40dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="10dp"
android:layout_marginTop="4dp"
android:src="@drawable/ic_launcher">
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@+id/label"
android:textSize="20dp" >
我不希望它的可见性设置为GONE时占用额外的列表项。正如文档中所述。
GONE – This view is invisible, and it doesn’t take any space for
layout purposes.
任何想法如何使它不占用空间?
谢谢,
丹尼斯xx
P.S。我的listview是在FoldersFragment ListFragment里面,这里是我的MainActivity的xml,其中FoldersFragment呈现
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
android:id="@+id/foldersFragment"
android:layout_width="200dip"
android:layout_height="match_parent"
class="com.example.fragments.FoldersFragment" >
android:id="@+id/detailFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.example.fragments.DetailFragment" >