Die Ansicht setVisibility (GONE) wird unsichtbar, belegt jedoch weiterhin Speicherplatz
Ich habe eine Ansicht, die effektiv eine Schaltfläche ist. Hier ist das XML-Layout (add_new.xml)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<Button
android:id="@+id/buttonNew"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/bText"
android:onClick="addNew"/>
</LinearLayout>
Wenn ich seine Sichtbarkeit auf GONE so einstelle
v = getActivity().getLayoutInflater().inflate(R.layout.add_new, null);
v.setVisibility(View.GONE);
es verschwindet, nimmt aber immer noch Platz ein. So was:
Diese Schaltfläche ist eine Kopfzeile in derListView
, die durch diese xml definiert ist:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/porno" >
<ImageView
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">
</ImageView>
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@+id/label"
android:textSize="20dp" >
</TextView>
</LinearLayout>
Und ich möchte nicht, dass es ein zusätzliches Listenelement belegt, wenn seine Sichtbarkeit auf GONE gesetzt ist. Wie in der Dokumentation angegeben.
GONE - Diese Ansicht ist unsichtbar und benötigt keinen Platz für Layoutzwecke.
Irgendwelche Ideen, wie man es NICHT dazu bringt, Platz einzunehmen?
Danke, Dennis xx
P.S. Meine Listenansicht befindet sich in einem FoldersFragmentListFragment
und hier ist die XML meiner MainActivity, in der FoldersFragment vorgestellt wird
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<fragment
android:id="@+id/foldersFragment"
android:layout_width="200dip"
android:layout_height="match_parent"
class="com.example.fragments.FoldersFragment" >
</fragment>
<fragment
android:id="@+id/detailFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.example.fragments.DetailFragment" >
</fragment>
</LinearLayout>