Widok setVisibility (GONE) staje się niewidoczny, ale nadal zajmuje miejsce
Mam widok, który skutecznie jest przyciskiem. Oto jego układ XML (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>
Kiedy ustawiłem jego widoczność na GONE w ten sposób
v = getActivity().getLayoutInflater().inflate(R.layout.add_new, null);
v.setVisibility(View.GONE);
znika, ale nadal zajmuje przestrzeń. Lubię to:
Ten przycisk jest nagłówkiem wListView
, który jest zdefiniowany przez ten xml:
<?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>
I nie chcę, aby zajmował dodatkowy element listy, gdy jego widoczność jest ustawiona na GONE. Jak podano w dokumentacji.
GONE - Ten widok jest niewidoczny i nie zajmuje miejsca na układ.
Jakieś pomysły na to, jak NIE zajmować miejsca?
Dzięki, Dennis xx
P.S. Mój widok listy znajduje się wewnątrz folderu FoldersFragmentListFragment
a oto xml mojego MainActivity, w którym prezentowany jest FoldersFragment
<?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>